cocoa-touch

Does a collection send a -release message to all objects it holds, if I send it an -release?

I've been reading that if an collection "gets released" it releases all it's objects as well. On the other hand, I was also reading that a collection would release it's objects as soon as the collection gets deallocated. But the last thing may not always happen, as apple says. The system decides if it's good to deallocate or not. In mos...

Graph generation on iPhone

Anyone have experience with drawing graphs on the iPhone? Looks like GraphKit isn't an option, so it's up to the programmer to either write his own library (using OpenGL, I guess), or an existing library. I can't seem to find any libraries that are confirmed to work on the iPhone. If you've written your own how did you go about it (op...

Possible to switch out View Controllers managed by a UINavigationController?

I am breaking the normal paradigm of a UINavigationController, or at least I'm trying to. We know that the Navigation Controller manages navigation via a stack. If I initialize with root controller A, navigate to B, and then Navigate to C, the Stack will look like - C/B/A. What I want to do though, is have a button on view C that will...

Are there any reasons why I should prefer an NSArray instead of NSMutableArray?

I feel that when I use NSArray, I might constraint myself some time in future. Are there any good reasons to prefer this "primitive" one instead of the "complex" one, which is mutable? ...

How to pass data to a UITabBarController

Hi, my app features a UITabBarController, which brings up some views. In the AppDelegate, I have to pass a (custom) model to it. Is the best way subclassing, or is there some better method? If I get it managed to have the model (e.g. Notes) in my UITabBarController, how do I access it out of the ViewControllers? Regards ...

How are objects in an autorelease pool referenced?

I am wondering if the autorelease pool holds strong or weak references to the objects it holds. I would guess they are weak. When I add an object to an autorelease pool, it's just not immediately released but will be released when the pool is drained, right? So the references should be weak, i.e. the reference count (or retain count) kee...

What's the difference between sending -release or -drain to an Autorelease Pool?

In many Books and on many Sites I see -drain. Well, for an Autorelease Pool that sounds cool. But does it do anything other than an release? I would guess -drain just makes the Pool to -release all it's objects, without releasing the Pool itself. Just a guess. ...

Where are all the pre-installed autorelease pools in iPhone applications?

I am wondering how many there are, and where they are. As I have seen in a Stanford Vid, there is one autorelease pool installed in the event loop of an iPhone App. But I think I missed the point where exactly that is? And are there any other autorelease pools that I should know about? ...

iPhone SDK - navController pushViewController - not responding..

I have a view that has a navigationController with two buttons, START (essentially a login button) and SETTINGS. When I click SETTINGS, the settings view appears and dismisses as planned. I can click on settings and then click back many times without anything crashing. Good. Now, when a user clicks START, I call the SHOWLOGOFFBUTTONS me...

Is there a preferred method of database management/object persistence on the iPhone?

I've seen several approaches, and each seem to have significant plusses and minuses. I'm learning iPhone development, I'm building a relatively simple app, which, at it's core, is really not much more than CRUD operations on 3 or four related entities. I'm used to ActiveRecord-type object persistence. The implementations for Cocoa Touch...

How to write a simple Ping method in Cocoa/Objective-C

I need to write a simple ping method in Cocoa/Objective-C. It also needs to work on the iPhone. I found an example that uses icmp, will this work on the iPhone? I'm leaning towards a solution using NSNetServices, is this a good idea? The method only needs to ping a few times and return the average and -1 if the host is down or unreach...

is the main.m really the place, where the autorelease pool of the main run loop is created by every event?

#import <UIKit/UIKit.h> int main(int argc, char *argv[]) { NSLog(@"new event..."); NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; int retVal = UIApplicationMain(argc, argv, nil, nil); [pool release]; return retVal; } If that's the case, then the main() function would have to be called on every event, ...

How does multithreading on iPhone OS work? How do I use it?

I am curious about threads on iPhone. Are they easy to establish and to maintain? How does it work on the iPhone? Is it real multithreading? ...

Is there a way to see what's exactly going on in UIApplicationMain()?

A long time ago I came accross a piece of code from an Cocoa Touch class. I was able to see what's going on exactly. Unfortunately I dont remember where that was. I'd like to see what UIApplicationMain() exactly does. Just for interest. ...

C preprocessor on Mac OSX/iPhone, usage of the '#' key?

I'm looking at some open source projects and I'm seeing the following: NSLog(@"%s w=%f, h=%f", #size, size.width, size.height) What exactly is the meaning of '#' right before the size symbol? Is that some kind of prefix for C strings? ...

Is it possible to add an object to a specific autorelease pool?

In the docs there is an addObject: method of NSAutoreleasePool. I thought about this: NSString *myString = [[NSString alloc] initWithCString:"Does this work?"]; [thePool addObject:myString]; [anotherPool addObject:myString]; Is that possible? I always read that I can only add objects to the topmost one on the autorelease pool stack. ...

Best practices for validating email address in Objective-C?

What is the cleanest way to validate an email address that a user enters that is Cocoa-Touch 2.0 compatible? ...

jpg or png for UIImage -- which is more efficient?

I am grabbing an image from the camera roll and then using it for a while as well as save it to disk as a PNG on the iPhone. I am getting the odd crash, presumably due to out of memory. Does it make a difference if I save it as PNG or JPG (assuming I choose note to degrade the quality in the JPG case)? Specifically: is more memory t...

UILabel - autoresize

Hi, How is it possible to resize size of text in UILabel in order to fit in the label? (I don't want those 3 dots to appear) Thank you in advance. ...

Why should a self-implemented getter retain and autorelease the returned object?

Example: - (NSString*) title { return [[title retain] autorelease]; } The setter actually retained it already, right? and actually nobody should bypass the Setter... so I wonder why the getter not just returns the object? It's actually retained already. Or would this just be needed in case that in the mean time another objects get...