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
451
votes
13 answers

How to print out the method name and line number and conditionally disable NSLog?

I'm doing a presentation on debugging in Xcode and would like to get more information on using NSLog efficiently. In particular, I have two questions: is there a way to easily NSLog the current method's name / line number? is there a way to…
rein
  • 32,967
  • 23
  • 82
  • 106
450
votes
35 answers

UIView with rounded corners and drop shadow?

I’ve been working on an application for a couple of years and received a simple design request: Round the corners on a UIView and add a drop shadow.To do as given below. I want a custom UIView... : I just wanted a blank white view with rounded…
Aditya Vaidyam
  • 6,259
  • 3
  • 24
  • 26
443
votes
31 answers

Text inset for UITextField?

I would like to inset the text of a UITextField. Is this possible?
RunLoop
  • 20,288
  • 21
  • 96
  • 151
419
votes
17 answers

How to use background thread in swift?

How to use threading in swift? dispatchOnMainThread:^{ NSLog(@"Block Executed On %s", dispatch_queue_get_label(dispatch_get_current_queue())); }];
Anshul
  • 4,386
  • 3
  • 12
  • 11
419
votes
15 answers

Add an element to an array in Swift

Suppose I have an array, for example: var myArray = ["Steve", "Bill", "Linus", "Bret"] And later I want to push/append an element to the end of said array, to get: ["Steve", "Bill", "Linus", "Bret", "Tim"] What method should I use? And what about…
Fela
  • 26,730
  • 8
  • 26
  • 24
417
votes
9 answers

Is It Possible to NSLog C Structs (Like CGRect or CGPoint)?

I want to be able to debug C structures without having to explicitly type every property that they consist of. i.e. I want to be able to do something like this: CGPoint cgPoint = CGPointMake(0,0); NSLog(@"%@",cgPoint); Obviously the '%@' won't…
mazniak
  • 5,849
  • 6
  • 28
  • 23
414
votes
19 answers

Set UIButton title UILabel font size programmatically

I need to set the font size of the title UILabel of a UIButton programmatically.
syam s
406
votes
21 answers

Can you animate a height change on a UITableViewCell when selected?

I'm using a UITableView in my iPhone app, and I have a list of people that belong to a group. I would like it so that when the user clicks on a particular person (thus selecting the cell), the cell grows in height to display several UI controls for…
Ted
397
votes
31 answers

Converting String to Int with Swift

The application basically calculates acceleration by inputting Initial and final velocity and time and then use a formula to calculate acceleration. However, since the values in the text boxes are string, I am unable to convert them to…
Marwan Qasem
  • 3,981
  • 2
  • 12
  • 4
393
votes
9 answers

How do I convert NSMutableArray to NSArray?

How do I convert NSMutableArray to NSArray in objective-c?
marcy
  • 4,213
  • 3
  • 23
  • 14
391
votes
33 answers

How do you add multi-line text to a UIButton?

I have the following code... UILabel *buttonLabel = [[UILabel alloc] initWithFrame:targetButton.bounds]; buttonLabel.text = @"Long text string"; [targetButton addSubview:buttonLabel]; [targetButton bringSubviewToFront:buttonLabel]; ...the idea…
Owain Hunt
  • 4,619
  • 2
  • 20
  • 10
386
votes
7 answers

UILongPressGestureRecognizer gets called twice when pressing down

I am detecting if the user has pressed down for 2 seconds: UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self …
383
votes
31 answers

Easy way to dismiss keyboard?

I have quite a few controls scattered throughout many table cells in my table, and I was wondering if there's an easier way to dismiss the keyboard without having to loop through all my controls and resigning them all as the first responder. I guess…
Seventoes
  • 4,810
  • 3
  • 19
  • 19
374
votes
4 answers

How to write iOS app purely in C

I read here Learn C Before Objective-C? Usually I then replace some Obj-C code with pure C code (after all you can mix them as much as you like, the content of an Obj-C method can be entirely, pure C code) Is this true? Is it possible to build an…
001
  • 62,807
  • 94
  • 230
  • 350
366
votes
30 answers

How do I add 1 day to an NSDate?

Basically, as the title says. I'm wondering how I could add 1 day to an NSDate. So if it were: 21st February 2011 It would become: 22nd February 2011 Or if it were: 31st December 2011 It would become: 1st January 2012.
Andrew
  • 15,935
  • 28
  • 121
  • 203