Questions tagged [cocoa-touch]

The Cocoa Touch Frameworks that drive iOS apps share many proven patterns found on the Mac, but were built with a special focus on touch-based interfaces and optimization.

Cocoa Touch is Apple's application-development framework for , consisting of Foundation, UIKit (), and Core Data ().

The Cocoa Touch frameworks that drive apps share many proven patterns found on the , but were built with a special focus on touch-based interfaces and optimization.

For development, see .

For Cocoapods, see .

Many Cocoa Touch questions deal with , , , or .

Debugging techniques

Cocoa programs can be debugged with many techniques and tools, both general and specific to , , , and .

Apple's Technical Note about debugging iOS applications

34585 questions
51 answers

Vertically align text to top within a UILabel

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?
  • 28,843
  • 15
  • 64
  • 76
39 answers

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

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…
Brock Woolf
  • 46,656
  • 50
  • 121
  • 144
27 answers

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

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…
  • 44,963
  • 37
  • 98
  • 104
81 answers

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

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>…
Guillaume Dubois
  • 2,003
  • 3
  • 13
  • 4
42 answers

How can I disable the UITableView selection?

When you tap a row in a UITableView, the row is highlighted and selected. Is it possible to disable this so tapping a row does nothing?
  • 38,604
  • 37
  • 87
  • 93
41 answers

Get the length of a String

How do you get the length of a String? For example, I have a variable defined like: var test1: String = "Scott" However, I can't seem to find a length method on the string.
Scott Walter
  • 9,426
  • 4
  • 18
  • 23
32 answers

Loaded nib but the 'view' outlet was not set

I added a new nib file to my project, and tried to load it. However, when I click on the toolbar icon that is supposed to take me to the view that I created, I get an NSInternalInconsistencyException with the message: Terminating app due to…
  • 10,839
  • 8
  • 26
  • 31
32 answers

Can I embed a custom font in an iPhone application?

I would like to have an app include a custom font for rendering text, load it, and then use it with standard UIKit elements like UILabel. Is this possible?
Airsource Ltd
  • 32,379
  • 13
  • 71
  • 75
34 answers

Eliminate extra separators below UITableView

When I set up a table view with 4 rows, there are still extra separators lines (or extra blank cells) below the filled rows. How would I remove these cells?
  • 9,821
  • 8
  • 35
  • 52
63 answers

Placeholder in UITextView

My application uses an UITextView. Now I want the UITextView to have a placeholder similar to the one you can set for an UITextField. How to do this?
16 answers

@class vs. #import

It is to my understanding that one should use a forward-class declaration in the event ClassA needs to include a ClassB header, and ClassB needs to include a ClassA header to avoid any circular inclusions. I also understand that an #import is a…
  • 48,756
  • 50
  • 150
  • 175
38 answers

Attempt to present UIViewController on UIViewController whose view is not in the window hierarchy

Just started using Xcode 4.5 and I got this error in the console: Warning: Attempt to present < finishViewController: 0x1e56e0a0 > on < ViewController: 0x1ec3e000> whose view is not in the window hierarchy! The view is still being presented and…
Kyle Goslan
  • 10,748
  • 7
  • 26
  • 41
9 answers

What does the NS prefix mean?

Many classes in Cocoa/Cocoa Touch have the NS prefix. What does it mean?
  • 20,990
  • 22
  • 84
  • 93
13 answers

Cocoa: What's the difference between the frame and the bounds?

UIView and its subclasses all have the properties frame and bounds. What's the difference?
  • 25,873
  • 32
  • 98
  • 137
21 answers

Giving UIView rounded corners

My login view has a subview which has a UIActivityView and a UILabel saying "Signing In…". This subview has corners which aren't rounded. How can I make them round? Is there any way to do it inside my xib?
  • 24,525
  • 45
  • 110
  • 156
2 3
99 100