Skip to content
archive

stack-overflow-ios-2026-06-05

Swift · · 3 min read

Top Voted iOS Questions on Stack Overflow — 2026-06-05

10 questions


Vertically align text to top within a UILabel

Score: 2350 | Answers: 51 | Views: 780525 | 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: 665734 | Tags: ios, objective-c, uiscrollview, uitextfield, uikeyboard

With the iOS SDK: I have a UIView with UITextField s 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 need a UIScrollView . I've tried changing the class of my UIView to a UIScrollView , but I'm still unable to scroll


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

Score: 1618 | Answers: 29 | Views: 720566 | Tags: ios, uitableview, autolayout, row-height

How do you use Auto Layout within UITableViewCell s 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: 997136 | 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 domain is example.com .


Passing data between view controllers

Score: 1503 | Answers: 44 | Views: 535047 | 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 multiple selections. How do I transfer the data from one view to another? I will be holding the selections


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

Score: 1413 | Answers: 37 | Views: 526742 | 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 seems bad), and while I could check to see for a response from some other websites if Google didn't


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

Score: 1334 | Answers: 82 | Views: 1049312 | 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 value coding-compliant for the key XXX.' What does this mean & How can I fix it?


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 *sortedArray = [drinkDetails sortedArrayUsingSelector:@selector(???)]; In Java I would make my object implemen


performSelector may cause a leak because its selector is unknown

Score: 1305 | Answers: 19 | Views: 193261 | 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 exists or not, but why would that cause a leak? And how can I change my code so that I don't get this war