objective-c

Release in iPhone

hello all, Whenever I read about how to avoid memory leaks, I always came across a concept that "Number of alloc must be equal to number of release". But I came across a concept where we require more than one release. Like What I used to practise was as follows: (NSString*) func1 { NSString* result = [[NSString alloc] initWithFor...

Why are my C++ exceptions not being caught?

I have some C++ code that uses a very standard exception pattern: try { // some code that throws a std::exception } catch (std::exception &e) { // handle the exception } The problem is that the exceptions are not being caught and I cannot figure out why. The code compiles to a static library in OS X (via Xcode). The library is l...

What does the & symbol mean in Objective-C?

What does the & symbol mean in Objective-C? I am currently looking at data constucts and am getting really confused by it. I have looked around the web for it but have not found an answer at all. I know this is possibly a basic Objective-C concept, but I just can't get my head around it. For example: int *pIntData = (int *)&incomingPa...

Do all class methods return an autoreleased object?

I'm re-reading the first few chapters of Cocoa Programming for Mac OS X and the author states that one of NSCalendarDate's class method returns an autoreleased object. I always assumed that all class methods returned an autoreleased object (since there's no alloc involved). Are there any class methods which you have to specifically reta...

Two Base64 encodings yield same decoding

Is it expected behavior that two encodings can map to the same decoding? I'm trying to troubleshoot a digital signature issue by doing sanity checks on base64-encoded intermediate strings. For example, the following base64 encoding: R0VUDQoNCg0KRnJpLCAwNCBTZXAgMjAwOSAxMTowNTo0OSBHTVQrMDA6MDANCi8= and: R0VUCgoKRnJpLCAwNCBTZXAgMjAwOSA...

How to perform simple search using valueForKeyPath of a model class in an array?

I have a model class that has "name" and "description". I would to perform a search using valueForKeyPath. For example, using loop I would perform the search this way: for (Model model in allModels) { if (mode.name == "name" || [absoluteURL rangeOfString:@"my_substring"].location == NSNotFound ) { // put this model in a result lis...

Obj-C... "Incompatible types in initialization" error

My code: CGPoint *tp_1 = CGPointMake(160, 240); gives an "Incompatible types in initialization" error... why is this?? ...

Regarding iPhone Application Developer Interview Preparation

I have to appear for iPhone Application Developer.. So, for that i need some links that shows me some overview of interview questions regarding Objective-C or cocoa framework... If you have any links then please provide me. Thanks.. ...

objective c 101 (retain vs assign) NSString

A 101 question Let's say i'm making database of cars and each car object is defined as: #import <UIKit/UIKit.h> @interface Car:NSObject{ NSString *name; } @property(nonatomic, retain) NSString *name; Why is it @property(nonatomic, retain) NSString *name; and not @property(nonatomic, assign) NSString *name; I understand that A...

Dynamic object creation and release

Hi, I have a class that instances some other classes. It's working to control their lifespan, or supposed to ;) A root class managing others which contain events and are subviews of the root view. I have a lot of graphics involved per view and need to clear things out before loading the next. Any idea how to unload the current subview...

Finding the event generator in obj c

Hi, I have a view with several subviews which in turn have several subviews. If I fire an event, say touches ended, in one of the bottom level views, how can I see what that event generating view was in the root view or second level view? Additionally any idea how to catch that event and then release the mid level view which would in t...

SubViewTwoController undeclared (first use in this function) (obj-c)

Ahoy hoy everyone :) Here is a list of links. You will need it when reading the post. I am a newbie to Objective-C and try to learn it for iPhone-App-Development. I used the tutorial linked in the link list to create a standard app with a simple basic Navigation. This app contains a "RootView" that is displayed at startup. The startup...

Watching messages to an object in Xcode debugger

I'd like to use gdb or Xcode's debugger to watch every message sent to an object in an Objective-C 2.0 program. I don't care about arguments and such, as I just need to see every message it receives (retain, release, autorelease, etc). I also don't want to profile my entire program. Is there a means, in Xcode, to select an instance (p...

How do I get the icon of the user's Mac?

Using Objective-C and Cocoa, does anyone know how to get the icon for a user's computer (the one that shows under "Devices" and "Network" in Finder)? Not the harddisk icon, the actual one for a user's device. It ranges from a macbook icon to the mac pro "tower" icon to a Windows blue screen of death monitor icon. I've tried stuff along ...

Do warnings matter?

EDIT: I have fixed all but two warnings now, so thank you all for the advice and the encouragement. The two warnings I have left would require me to change the database: /Locations.xcdatamodel:tiles.Map: warning: tiles.Map -- relationship does not have an inverse /Locations.xcdatamodel:Waypoint.description: warning: Waypoint.descripti...

How to capture system stats on the iPhone?

I'm trying to write an iphone app that would mimic the top system utility available on *nix systems. It seems as if system() and/or popen() should enable me to capture output from system commands executed on the iphone. However, the following code gives no output for either popen or system. Is there some other way of getting this info...

How to resize a UITableViewCell's accessoryView based on size of cell?

Is it possible for a UITableViewCell's accessory view to be sized based on the size of the UITableViewCell that owns it? How can I achieve this? ...

Multiple Delegates in Objective C

I'm coming from the C# event model, and I'm wondering if there is a standard way to notify multiple delegates of an event? I have a ClassCDelegate protocol that I want both ClassA and ClassB to implement. Is there a way I can assign an instance of ClassC both ClassA and ClassB as delegates without having to manually create a list of del...

Selling an Upgrade to a Full-Featured iPhone App

Hello, I have two iPhone apps - one provides maps, online and off. The other includes the map application, and also provides a GPS recorder. I would like to sell the Offline Maps app, and then have an option within the app to upload to the full application. How would I go about doing this? In my code, I build two different targets aga...

Reference parent object

I currently have NSXMLParser working in my viewcontroller. I would like to create a new class that will have the 2 data elements as properties and do all of the xmlparsing. The problem I have is getting the new class to "alert" the parent when it is done parsing, etc. So the viewcontroller (the parent) can then turn off the activity indi...