Skip to content
archive

stack-overflow-ios-2026-06-03

Swift · · 3 min read

Top Voted #ios Questions

Vertically align text to top within a UILabel ⭐2350 💬51

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? ⭐1953 💬28

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? ⭐1798 💬99

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 ⭐1618 💬29

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 ⭐1613 💬30

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 ⭐1503 💬44

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? ⭐1413 💬37

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? ⭐1334 💬82

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? ⭐1324 💬27

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 ⭐1305 💬19

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 ...