objective-c

How to load image from NSMutableArray

I want to load the image URL from my NSMutableArray. Here is my Code: id path = (NSString *)[[stories objectAtIndex: storyIndex] objectForKey: @"icon"]; NSURL *url = [NSURL URLWithString:path]; NSData *data = [NSData dataWithContentsOfURL:url]; UIImage *img = [[UIImage alloc] initWithData:data cache:NO]; If I use: id path = @"http://w...

Does Objective-C guarantee the initialization of interface member data?

In an interface such as this: @interface MyClass : NSObject { bool PlainOldBool; } @end ... does PlainOldBool get auto-initialized to false, or is it necessary to use an init method to do that explicitly? ...

NSNumber >= 13 won't retain. Everything else will.

The code I'm currently working on requires adding an NSNumber object to an array. All of the NSNumbers with value 0-12 are added fine, but 13 onward causes a EXC_BAD_ACCESS. I turned on NSZombieEnabled and am now getting *** -[CFNumber retain]: message sent to deallocated instance 0x3c78420. Here's the call stack: #0 0x01eac3a7 in ___fo...

xcode - warning there's no getter/setter for property not even mentioned in the code!!

I got the warning : property 'textField' requires method '-textField' to be defined - use @synthesize, @dynamic or provide a method implementation. Now, there is no such property defined in my project! More bizarre, if I just click save in Interface builder and build again, the build is successful - though, right on the line ...

What is a "delegate" in Objective C's iPhone development?

What is a "delegate" in Objective C's iPhone development? ...

Unable to load UIView with initWithNibName in Apple SDK 3.1.3

I am trying to load my UIViewController and corresponding UIView programmatically in the AppDelegate class. I have the following in the applicationDidFinishLaunchingMethod of the AppDelegate class: (void)applicationDidFinishLaunching:(UIApplication *)application { NSLog(@"--- AppDelegate applicationDidFinishLaunching Start"); // Over...

UIScrollView carousel menu

Hi all, I'm trying to figure out if I can get what I want out of UIScrollView through some trickery or whether I need to roll my own scroll view I have a series of items in row that I want to scroll through. One item should always be centered in the view, but other items should be visible to either side. In other words, I want normal sc...

Int or NSInteger as object for method argument. Objective-C

Hi. I'm having some trouble passing a number as an argument for a method: -(void) meth2:(int)next_int; And to call that method i need this: int next_int = 1; [self performSelectorOnMainThread:@selector(meth2:) withObject:next_int waitUntilDone:NO]; //update next_int and call meth2 again at this point i get a "pointer from integer w...

What's the performance penalty of using isKindOfClass in Objective C?

I'm considering introducing: if ([myInstance isKindOfClass:[SomeClass class]]) { do something...} into a piece of code that gets called pretty often. Will I introduce a significant performance penalty? In Objective C, is there a quicker way of assessing whether a given object instance is of certain class type? For example, is the f...

UIImageView Fade-In Dissapears

I have this code which should create a splash image with either no animation or a fade in, then call code to dismiss the image out after a delay. The SplashViewAnimationNone works fine and creates the full screen image, but the Fade code fades the image in but then immediately disappears. - (void)startSplash { [[[[UIApplication sh...

Why does this only work sometimes? (UITextView resign first responder question)

When a user presses the "SEND"(return) button I want the keyboard to retract and do other stuff like send a message. But it only works SOMETIMES... Why does this code only work SOMETIMES? I need it to work all the time obviously, but it doesn't. - (void)textViewDidChange:(UITextView *)inTextView { NSString *text = myTextView.text;...

Highlight table view cells when user drags across rows

I have a grouped table view that does not need to scroll. I'd like each cell to highlight as the user moves their finger down the screen and call didSelectRowAtIndexPath on release. This behaviour can be seen done by apple in 'settings > mail > add account'? I can't seem to replicate it myself, all I can get is the default, where the c...

Extract values between parenthesis from NSString

I have an NSString that will be something like "xxxx (yyyyy)" where x and y can be any character. I'd like to extract just the y from inside the parenthesis. I managed to extract the x using a NSScanner but I haven't figured out the proper way to extract out the y. ...

Objective-C Framework for registering an app?

Does anyone know of an Objective-C framework that takes care of registering an app? I'm interested in the GUI/30-day trial side more than the actual verifying of serial numbers. ...

Objective-C optimization

Are there standard optimization tricks for Objective-C to make for faster execution along the lines of "inlining" frequent methods as in C++ or the "g++ -fast" tag? Edit: Does anyone have a short example using SEL and IMP when theMethod has two (or more) integers for input? ...

Core Data Inferred Migration – Automatic "lightweight" vs Manual

I've updated the model of an existing iPhone app in some simple ways (remove attribute, add attribute, remove index), and can use automatic lightweight migration to migrate the persistent store. Due to the typical size of the data set, the processing time is not insignificant, and warrants feedback for the user. NSMigrationManager prov...

Outputting a bar chart to an iPhone application?

Right, I really want to output a Bar Graph to an Obj-C iPhone application - now I may be missing a vital SDK class or something; but right now my solution is to embed a WebView and inside that have a JQuery/Flot based graph - not totally ideal I know! Just wondering if anybody has any other creative solutions or whether a WebView/AJAX s...

protobuf-net - backticks, Dictionaries & .proto files

I'm trying to talk to a C# program that uses protobuf-net from an iphone using http://code.google.com/p/metasyntactic/wiki/ProtocolBuffers Unfortunately the .proto file I've been given (generated from the C# source code) includes an a line that protoc is rejecting: repeated Pair_Guid_List`1 Local = 6; It appears that this is because ...

Executing codes in viewDidLoad

In my .m file : (void)viewDidLoad { [super viewDidLoad]; /* Some codes for picker view and slider */ } I used a button to navigate to second view by using the below code: (IBAction)goToPlay{ [self presentModalViewController: secondViewController animated: YES]; } I used another button to go back to first view by using be...

How to change permission of a directory recursively using NSFileManager setAttributes

I'm currently using NSFileManager setAttributes to change the permission of a directory. My problem is that it doesn't appear to do so recursively. Is there any way to force it to do so? ...