objective-c

How to write data in plist?

Hi to all, I have created save.plist in resource folder. I have written some data within that directly (without using coding). I am able to read that data but I cant able write through coding into the same save.plist. By using following code I am trying to write the data but it get stored within my .app plist. The code is here NSString...

How to lay out an iPhone page

I want to implement a description page in an iPhone app. It's the final page in a drill-down navigation structure and needs to include a title, description, icon, large image, date and some buttons the user can click on to activate another application. The information comes from an external source and the title, description and image all...

editButtonItem set but no minus buttons?

My edit button is placed in viewDidLoad: self.navigationItem.rightBarButtonItem = self.editButtonItem; It shows up correctly on the nav bar, and tapping this button indeed change it to Done. However, no minus buttons show up in my table rows. Swiping a row, then tap Delete works, though. Any ideas? EDIT 1: Here's how I'm doing: - (...

iphone: resizing the view when the device is rotated

I am trying to develop an application which is geo-sensetive. So, I have written - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // Return YES for supported orientations // return (interfaceOrientation == UIInterfaceOrientationPortrait); return YES; } I have put different imag...

Referencing a nib file in a subfolder of an Xcode compiled Cocoa app bundle.

If I have a directory in my Xcode project (not a Group), which is added to the main target, and compile it, how do I instruct an NSViewController to initWithNibName:bundle: a nib file inside that directory? I've tried [viewController initWithNibName:@"FolderName/NibName" bundle:nil], but that doesn't work. Neither does without the folde...

Events for custom UIView

What's the best way for registering events for my UIView subclass, so that I can connect them to IBAction-s in interface builder? Currently I've just got a standard UIView dropped onto my main view and I've set the class to "RadioDial" (my custom class). This displays the view fine, but I have no idea how to get events out of it. Thank...

onFocus method for the textField

I want to change the cursor position from one textField to another textField. I want set that programatically. How I do that? Is there any method for that in iPhone? ...

[self release], [self dealloc] or [super dealloc] in init methods?

I've just been reading up on how to properly fail in an init method and the docs seem to disagree with each other. One recommends throwing an exception while the others recommend cleaning up and returning nil. What's the current best practice here? ...

Objective C Memory Management Confusion

I was reading the apple documentation for memory management, and came across something that I just don't understand. Basically, I don't understand why one does not need need to retain an instance variable through the "getter" method. I wrote this little program to see what would happen. I thought there would be a crash, but I am obvio...

Cost of message dispatch in Objective-C

I'm curious to know about the cost of message dispatch in Objective-C in various situations. Particularly I want to guide my choice of program design so I'm not tempted to prematurely optimize by avoiding message dispatches when they would make for a better design. A case in my current project is that I have a class with instance variab...

Using the value of a string to determine the instance of a class

I have a switch statement similar to this one: switch (number) { case 1: if (imageView1.hidden == NO) { imageView1.hidden = YES; } else { imageView1.hidden = NO; } break; case 2: if (imageView2.hidden == NO) { imageView2.hidden = YES; } else { imageView2.hidden = NO; ...

UIWebView - How to identify the "last" webViewDidFinishLoad message?

The webViewDidFinishLoad message seems to be sent each time any object in the page has been loaded. Is there a way to determine that all loading of content is done? ...

NSDictionary Objective-C

I'm trying to store data in the following fashion with a string as the key and I would like an array as the value. key objects "letters" {'a','b','c','d'} "numbers" {1,2,3,4,5,6,7} Is this possible with NSDictionary in code? If so how would that look like? I'm really confused on this. ...

Objective-C asynchronous callback from

Hi all, I'm trying to make a class that handles some NSURLConnection and authentication stuff and then makes a callback to downloadFinished when it has completed the didReceiveData event. How exactly does that work in Objective-C? Thanks! #import "fetch.h" ... - (IBAction)downloadButton { fetch *downloader = [[fetch alloc] in...

multiline uibutton

how to set a multiline as title of a UIButton in iPhone programming pls help me .. thanks and regards .. ...

Covert NSString to NSDate in a different timezone

Hi I am trying to convert a string to date in a separate time zone from the current system time zone. I have set the time zone of the dateformatter to this timezone. But the NSDate I get is always in my current time zone. For instance, my current time zone is PDT. I have set the DateFormatter's time zone to CST. I have a string with th...

NSNumber out of scope?

I've written an Objective-C class and I'm using a shared instance of it across several of the views in my iPhone project. Its member variables include bools, ints, NSStrings and one NSNumber. The shared instance seems to work just fine across the scope of my application, except for the NSNumber which the debugger tells me is "out of scop...

NSTableView with custom cells

Hello there, it seems I've been searching for a long time and haven't found a great, easy, answer to my problem. I'm using XCode with Cocoa/ObjC and am trying to create an NSTableView which will load values from an NSDictionary/Array into different sections of a cell. For example, I'm trying to get an NSImage, NSTextField and other ite...

Another: NSString Compare Not Working in Objective-C

I'm trying to use the IsEqualToString method (which I have used succesfully before). But I get the following error: -[NSCFString IsEqualToString:]: unrecognized selector sent to instance 0xa055e7b0 Here is the code: @interface EditHabitViewController : UIViewController<UITableViewDataSource,UITableViewDelegate> { NSString *contactId;...

Creating iPhone Pop-up Menu Similar to Mail App Menu

I'd like to create a pop-up menu similar to the one found in the mail app when you want to reply to a message. I've seen this in more than one application so I wasn't sure if there was something built into the framework for it or some example code out there. ...