Skip to content
archive

stack-overflow-ios-2026-06-04

Swift · · 3 min read

Top iOS Questions on Stack Overflow — 2026-06-04

10 top-voted questions.

Vertically align text to top within a UILabel

Score: 2350 | Answers: 51 | Views: 780523

Tags: ios, cocoa-touch, uikit, uilabel, text-alignment

I have a UILabel with space for two lines of text. Sometimes, when the text is too short, this text is displayed in the vertical center of the label.

How do I vertically align the text to always be at the top of the UILabel?


What's the difference between the atomic and nonatomic attributes?

Score: 1953 | Answers: 28 | Views: 547689

Tags: ios, objective-c, properties, atomic, nonatomic

What do atomic and nonatomic mean in property declarations?

@property(nonatomic, retain) UITextField *userName; @property(atomic, retain) UITextField *userName; @property(retain) UITextField *userName;

What is the operational difference between these three?


How can I make a UITextField move up when the keyboard is present - on starting to edit?

Score: 1798 | Answers: 99 | Views: 665729

Tags: ios, objective-c, uiscrollview, uitextfield, uikeyboard

With the iOS SDK: I have a UIView with UITextFields that bring up a keyboard. I need it to be able to:

Allow scrolling of the contents of the UIScrollView to see the other text fields once the keyboard is brought up

Automatically "jump" (by scrolling up) or shortening

I know that I nee


Using Auto Layout in UITableView for dynamic cell layouts & variable row heights

Score: 1618 | Answers: 29 | Views: 720565

Tags: ios, uitableview, autolayout, row-height

How do you use Auto Layout within UITableViewCells in a table view to let each cell's content and subviews determine the row height (itself/automatically), while maintaining smooth scrolling performance?


Transport security has blocked a cleartext HTTP

Score: 1613 | Answers: 30 | Views: 997128

Tags: ios, xcode, ios9, ios10, app-transport-security

What setting do I need to put in my info.plist to enable HTTP mode as per the following error message?

Transport security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file.

Assume that my domai


Passing data between view controllers

Score: 1503 | Answers: 44 | Views: 535044

Tags: ios, objective-c, swift, model-view-controller, uiviewcontroller

I'm new to iOS and Objective-C and the whole MVC paradigm and I'm stuck with the following: I have a view that acts as a data entry form and I want to give the user the option to select multiple products. The products are listed on another view with a UITableViewController and I have enabled multipl


How can I check for an active Internet connection on iOS or macOS?

Score: 1413 | Answers: 37 | Views: 526739

Tags: ios, macos, cocoa, cocoa-touch, reachability

I would like to check to see if I have an Internet connection on iOS using the Cocoa Touch libraries or on macOS using the Cocoa libraries. I came up with a way to do this using an NSURL. The way I did it seems a bit unreliable (because even Google could one day be down and relying on a third party


Xcode - How to fix 'NSUnknownKeyException', Reason: "… this class is not key value coding-compliant for the key X" error?

Score: 1334 | Answers: 82 | Views: 1049309

Tags: ios, macos, cocoa, cocoa-touch, interface-builder

I'm trying to link a UILabel with an IBOutlet created in my class. My application is crashing with the following error"


Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x6e36ae0> setValue:forUndefinedKey:]: this class is not key va


How do I sort an NSMutableArray with custom objects in it?

Score: 1324 | Answers: 27 | Views: 487726

Tags: ios, objective-c, sorting, cocoa-touch, nsmutablearray

What I want to do seems pretty simple, but I can't find any answers on the web. I have an NSMutableArray of objects, and let's say they are 'Person' objects. I want to sort the NSMutableArray by Person.birthDate which is an NSDate.

I think it has something to do with this method:

NSArray *sortedAr


performSelector may cause a leak because its selector is unknown

Score: 1305 | Answers: 19 | Views: 193259

Tags: ios, objective-c, memory-leaks, automatic-ref-counting

I'm getting the following warning by the ARC compiler:

"performSelector may cause a leak because its selector is unknown".

Here's what I'm doing:

[_controller performSelector:NSSelectorFromString(@"someMethod")];

Why do I get this warning? I understand the compiler can't check if the selector