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

34593 questions
2255
votes
49 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?
Stefan
  • 28,004
  • 14
  • 62
  • 76
1356
votes
46 answers

How to 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
  • 44,051
  • 47
  • 117
  • 143
1290
votes
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…
rustyshelf
  • 44,085
  • 36
  • 96
  • 104
1231
votes
73 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. What does this mean? How can I fix it? *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason:…
Guillaume Dubois
  • 2,003
  • 3
  • 13
  • 4
1224
votes
41 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?
davidmytton
  • 35,554
  • 36
  • 83
  • 91
780
votes
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
  • 31,336
  • 13
  • 69
  • 74
772
votes
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…
John
  • 10,219
  • 7
  • 24
  • 30
747
votes
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?
RoundOutTooSoon
  • 9,281
  • 8
  • 29
  • 49
737
votes
62 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? Edit: Use this cocoapod: https://cocoapods.org/pods/UITextView+Placeholder
user142019
713
votes
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…
Coocoo4Cocoa
  • 41,896
  • 50
  • 148
  • 175
628
votes
34 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
  • 9,898
  • 7
  • 23
  • 38
607
votes
9 answers

What does the NS prefix mean?

Many classes in Cocoa/Cocoa Touch have the NS prefix. What does it mean?
Martin08
  • 19,490
  • 20
  • 80
  • 91
605
votes
11 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?
mk12
  • 24,644
  • 29
  • 92
  • 132
587
votes
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?
itsaboutcode
  • 21,936
  • 42
  • 103
  • 153
571
votes
18 answers

UITableViewCell, show delete button on swipe

How do I get the delete button to show when swiping on a UITableViewCell? The event is never raised and the delete button never appears.
TheLearner
  • 18,967
  • 35
  • 92
  • 162
1
2 3
99 100