objective-c

what is self? when should i use it?

can you explain me the self in the objective-C 2.0 ? when and where should i use? is it similar with this definition in java? ...

Open view with slide effect from bottom to top on iPhone

Hi all! I'm making an application for iPhone (which runs in landscape mode) (OS 3.0), and I want that when I touch a toolbar button it opens a view with a slide effect (similar to the effect when you touch 'Bookmarks' in Mobile Safari's toolbar) from the bottom to the top of the screen. The view is in the same XIB file as the button. H...

does using try catch block in xcode show error on real device?

my application is running fine in simulator...but not on real device....and i have jailbroken iphone so i am unable to debug through device...if i use try catch something like this @try { Statements } @catch (NSException *ex) { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:[NSString stringWithFormat:@"%@",ex...

The document NSBundle.h could no be saved

I'm having some troubles with the bundle and somehow I can't save images from bundle to docs directory any more. Now I've got this error before building: The document NSBundle.h could no be saved It apparently compiles well. This is the kind of code I'm using: //Get every name from plist array and append it to the full path for(...

for- loop in background thread accesses each index more than once --- iPhone dev

I have a method getImageData which I call as [self performSelectorInBackground:@selector(getImagesData ) withObject:nil]; in my viewDidLoad. getImageData has a for-loop i realised that each index in the loop is called more than once. I also access a static NSMutableArray in the loop. When i don't retain the array it gives me exc bad acce...

Un-Recognized Selector Sent to Instance Error.

I am building my App after adding some code but I get the Un-Recongnized Selector Sent to Instance Error stopping my App from running. Here's a Picture of the Error - This is the Code I added (it's for the data source of an NSOutlineView) - (id)init { self = [super init]; if (self != nil) { // initialization code, ro...

call action method for a uibutton without using interface builder in cocoa

I'm currently calling an action method in an object by dragging a button to the view in interface builder. I then drag an object to the panel and specify my object with the action method. I shift drag my button to the object and choose my action method. This works in calling my method. I would like to instead call my action method wi...

Simple objective-c question - function that returns a string

Hi, Silly as it may sound, I am trying to write a simple fuction in objective-c which returns a string and displays it, the following code nearly works but I can't get printf to accept the functions return value ... NSString* getXMLElementFromString(); int main(int argc, char *argv[]) { printf(getXMLElementFromString()); retur...

Using self->ivar when accessing instance variables directly

I have noticed that most Objective-C coders never use the self->ivar syntax when accessing instance variables directly. Most sample code that I see simply references the instance variable without self->. I think that it is rather confusing to reference an instance variable without making clear that it is an instance variable and not simp...

Performance problems reading in iPhone ABAddressBook

I am creating a lookup table mapping contact phone numbers to their corresponding ABRecordRef (I need this so I can efficiently look up contact names and photos based on the phone number a user has dialed). Unfortunately, for 500 contacts it takes around 4 seconds to loop through all the contacts and create my lookup table, which makes ...

Program Crash Upon Switching Between Tabs 5 Times

I've got a strange bug I'm not sure how to track down. I'm running an app in the Simmulator 3.0. It has three tabs on the tabBarcontroller, let's call them tab1, tab2, and tab3. All three tabs are a sub-class of a customized grouped table. If I click back and forth between tab1 and tab3 indefinitely, there is no trouble. However, if I cl...

Error on CLLocation subclassing

I'm trying to make a new CLLocation subclass. This is the skeleton: #import <UIKit/UIKit.h> #import <CoreLocation/CoreLocation.h> @interface JFLocation : CLLocation { } @end #import "JFLocation.h" @implementation JFLocation @end When I build the class I'm getting this errors: Undefined symbols: ".objc_class_name_CLLocation"...

Opening Files - Cocoa

How would I be able to open files from my application? For example, they type in the directory in a textfield called "inputBox" and they press the button open, to open the file. Thanks Kevin ...

Check if drawn path/CGPath intersects itself in an iPhone game

I have a path drawn in OpenGL ES. I can convert it to a CGPath if needed. How would I check if it intersects itself (If the user created a complete loop)? ...

Getting an XML file from URL to NSData object ?

Hello, I need to load a .xml file from a URL adress into an NSData object for further parsing with some libraries that I already own, ( but they ask me the .xml file as NSData ), how could I do this ? The url format would be something like this: http://127.0.0.1/config.xml ...

Objective-C/iPhone memory management question

In my iPhone app, I have a "statistics" view that is displayed by the following method - the method itself is called when the user touches a button. This method is in a UINavigationController - (void) showStatsView { StatsViewController *statsViewController = [[StatsViewController alloc] initWithNibName:@"Stats" bundle:[NSBundle mai...

How do I remove instance methods at runtime in Objective-C 2.0?

Is it possible to remove methods added to a class with class_addMethod? Or if I want to do this, must I keep creating classes at runtime with objc_allocateClassPair and adding different sets of methods to them to vary the methods implemented? I'll accept answers that include hackery :-) ...

When do I not need to specify File's Owner for a nib?

I have been reading up on File's Owner here on Stack Overflow and a few other resources, but I was left with one question. When do I not need a File's Owner for a nib? In chapter 8 of Exploring the iPhone SDK (a great book by the way) you design a table view cell nib. The author says the following: You might be wondering why we're not d...

indexPathForSelectedRow on previous UITableViews always returns nil?

I have a stack of UITableViews managed by a UINavigationController. When I try calling indexPathForSelectedRow on any of the previous UITableViews, I always get nil: NSEnumerator *e = [[navigationController viewControllers] objectEnumerator]; UITableViewController *controller; while (controller = [e nextObject]) { NSIndexPath *selec...

Create Unique String Iphone SDK 3.0

Hi, I wanted to create an unique string with length not more than 15 characters in objective C (or with the help of Iphone SDK 3.0). I need this for mysql table. I know mysql auto increment will do for primary key but I really need to send the unique key from Iphone Itself.Every record in my table had to have an unique key. The Unique...