Tag: objective c

Capitalize or change case of an NSString in Objective-C

I was wondering how to capitalize a string found in an object in an NSMutableArray. An NSArray contains the string ‘April’ at index 2. I want this to be changed to ‘APRIL’. Is there something simple like this? viewNoteDateMonth.text = [[displayDate objectAtIndex:2] capitalized];

iPhone UILabel text soft shadow

I know soft shadows are not supported by the UILabel out of the box, on the iPhone. So what would be the best way to implement my own one? EDIT: Obviously I will subclass the UILabel and draw in the -drawRect: My question is, how do I get the contents of the label as graphics […]

Use-case of `oneway void` in Objective-C?

I found a strange keyword in NSObject.h – (oneway void)release; I searched the web, and learned it relates to asynchronous message passing, which looks similar with Erlang’s message passing. It seems this can make many interesting things. What are some good use-cases of this keyword?

What happened to “HelveticaNeue-Italic” on iOS 7.0.3

Just upgraded my iPod touch to iOS 7.0.3 and “HelveticaNeue-Italic” seems to have disappeared. When I query on the phone with: [UIFont fontNamesForFamilyName:@”Helvetica Neue”] I get the following fontNames (13): HelveticaNeue-BoldItalic, HelveticaNeue-Light, HelveticaNeue-UltraLightItalic, HelveticaNeue-CondensedBold, HelveticaNeue-MediumItalic, HelveticaNeue-Thin, HelveticaNeue-Medium, HelveticaNeue-ThinItalic, HelveticaNeue-LightItalic, HelveticaNeue-UltraLight, HelveticaNeue-Bold, HelveticaNeue, HelveticaNeue-CondensedBlack When I do the same query running in the simulator I get […]

static variables in Objective-C – what do they do?

I’ve seen a few posts discussing what a static variable is and I think I get it – but I’d love to quickly write (or find) a program that utilizes both a regular and a static variable, side by side, and see how/when they operate differently. Some quick n dirty code, maybe two int vars […]

Objective-C class -> string like: -> @“NSArray”

I am trying to get a string name of a class from the class object itself. // For instance [NSArray className]; // @”NSArray” I have found object_getClassName(id obj) but that requires an instance be passed to it, and in my case that is needless work. So how can I get a string from a class […]

Objective-C respondsToSelector

From what I have learned so far: In Objective-C you can send any message to any object. If the object does implement the right method it will be executed otherwise nothing will happen. This is because before the message is sent Objective-C will perform respondsToSelector. I hope I am right so far. I did a […]

How do I flag a method as deprecated in Objective-C 2.0?

I’m part of a team developing a fairly large iPad app and there are many different classes we’ve created as a result. The trouble is some of the methods are now pretty much obsolete and I don’t want simply remove them yet as I know some parts of the overall system use the methods… but […]

Object allocate and init in Objective C

What is the difference between the following 2 ways to allocate and init an object? AController *tempAController = [[AController alloc] init]; self.aController = tempAController; [tempAController release]; and self.aController= [[AController alloc] init]; Most of the apple example use the first method. Why would you allocate, init and object and then release immediately?

How to handle Objective-C protocols that contain properties?

I’ve seen usage of Objective-C protocols get used in a fashion such as the following: @protocol MyProtocol <NSObject> @required @property (readonly) NSString *title; @optional – (void) someMethod; @end I’ve seen this format used instead of writing a concrete superclass that subclasses extend. The question is, if you conform to this protocol, do you need to […]