objective-c

What is the isa instance variable all about?

In the NSObject Class Reference they talk about an "isa instance variable" which is initialized to a data structure that describes the class can someone explain what I should know about this isa instance variable? What is that good for? What does isa mean? Sounds like a norm, like DIN, ISO, etc.; Any idea what that is? ...

What does this mean in iphone programming?

#pragma mark Internal API I've seen this in a book called xcode_quick_tour_iphoneOS. Does someone know about it? ...

How Do I write a method that takes an address to a pointer as a parameter?

Usign the NSString class method stringWithContentsOfFile:encoding:error I can: NSError *error; NSString *fileContent = [NSString stringWithContentsOfFile:... encoding:... error:&error] if (fileContent == nil) { NSLog(@"%@", error); } I would like to do something similar along the lines of: NSString *message; BOOL result = [self ch...

How to get a list of the playlists and songs in an iPhone/iPod Touch?

Can I get a list of the playlists and songs in each playlist in an iPhone? This is for a legal app. so hidden APIs/jailbroken solutions don't apply. ...

iPhone - how to save user settings from application?

Hi, What is the easiest way to save a couple of variables in an iPhone application in a long-term memory? I have an application that works with different sqlite databases and I want after exiting from an application to save last active database name in order to open last database when user enters an application again. It's a little bi...

(id) vs. (NSSomeObject *) in Objective-C/Cocoa?

Is it better practice to use id or NSSomeObject * when possible? I know the compiler can do better checking when it's explicit, but I was just wondering which is better practice. E.g.: - (IBAction)someButton:(id)sender vs. - (IBAction)someButton:(NSButton *)sender. Are there any benefits to either of those? ...

Fundamental Objective-C question...driving me crazy

Its been a long time since I've done any programming. Used to be 'ok' at reading C & C++...never wrote much. I have an extremely simple Class that I want to use to manipulate the contents of an Array (using NSMutableArray). The Array needs to persist as an Object so I can make multiple updates to it during a single run of my program (...

iPhone Data

I'm trying to extract about 72000 SInt32s from the iPhone, but not sure what the best approach is. Using printf or NSLog to the console basically crashes my program and my computer. I tried redirecting stderr to a file, but I run into the same problem. Was wondering what the best way is to extract this data so I can later use it on my...

Why don't I have to release these objects?

Here's an sample code, where only the "string" object is released. NSString *nameOfFile = ... ; NSError *error; NSString *string = [[NSString alloc] initWithContentsOfFile:nameOfFile encoding:NSUTF8StringEncoding error:&error]; if (string == nil) { // handle error } [string release]; I understand why the error object is not releas...

Global variables as aliases for singletons?

Hi! I'm developing a Cocoa (Touch) app and there's certain data (like own device information and a list of locations) that I have to persist between different views and controllers. I thought of storing it as instance variables in my App Delegate, but addressing the delegate is quite cumbersome (no joy typing [[[UIApplication sharedAp...

Is it possible to call a Python module from ObjC?

Using PyObjC, is it possible to import a Python module, call a function and get the result as (say) a NSString? For example, doing the equivalent of the following Python code: import mymodule result = mymodule.mymethod() ..in pseudo-ObjC: PyModule *mypymod = [PyImport module:@"mymodule"]; NSString *result = [[mypymod getattr:"mymeth...

draw path on map in iphone

I am using the Route-Me library for the iPhone. My problem is that i want to draw a path on the map for example. I am in Dallas and i want to go new york then just i will put marker on these two places and path will be drawn between this two marker. Can any body suggest me how this can be done. If any other Map rather than RouteMe th...

Calling assembly routine in objective C

Hi I have written a function nabs in assembly file math.nasm as follows %ifdef USE_x86_ASM SECTION .text cglobal nABS ;*------------------------* ;* int nABS(int a) * ;* return value in eax * ;*------------------------* ALIGN 16 nABS: push ebx ...... ...... pop ebx ...

Why should I send -autorelease to my instance variable in my setter method, rather than -release?

Apple is doing this in a setter method for an instance variable mainSprocket: – (void)setMainSprocket:(Sprocket *)newSprocket { [mainSprocket autorelease]; mainSprocket = [newSprocket retain]; return; } Why do they send -autorelease and not -release? Would a -release have a bad effect here? Actually it should not (for my u...

iphone global variable

I want to open my SQLite database in my appDelegate class and reference that database in all my other classes that need the database. I have tried using : static sqlite3 *database = nil; But when I try to reference it in my other classes with appDelegate.database, I get a compile error of "error: request for member 'database' in someth...

Autorelease and "assign" properties in Objective-C? (On iPhone)

I have an instance of a UITableView, and a separate class that adheres to the delegate and datasource protocols. I'm doing this like so: SubjectTableViewHandler *handler = [[[SubjectTableViewHandler alloc] init] retain]; tv.delegate = handler; tv.dataSource = handler; [handler autorelease]; I don't want to maintain the handler as an i...

No Data Returned Using NSURLConnection Asynchronously

Hi everyone, I am having a heck of time with something that seems rather straightforward but I can't seem to get working. I am building an iPhone app that retrieves data from a web host. I am trying to establish an asynchronous connection to the host as I want to keep the device freed up during the connection. (sendSynchronousRequest fr...

canonical way to randomize an NSArray in Objective C

Is there a canonical way to randomize an array in Objective C? ...

Passing float "byref" in Objective C?

Is there a way to pass a float "byref" to a method in objective C? Here's an overview of what I've got: method signature: - (void) MyMethod: (float*) min max:(float*) max; method: - (void) MyMethod: (float*) min max:(float*) max { } trying to invoke it: float min1 = 0; float max1 = 0; [self MyMethod: min:&min1 max:&max1]; I g...

Rule of thumb for @property atomicity in Objective-C?

Is there a good rule of thumb for when nonatomic properties should be used in Objective-C (on the desktop or on the iPhone platform), as opposed to the default atomic properties? I understand the difference – atomicity guarantees an entire value at the expense of performance – but most examples I see use nonatomic properties (and aren't ...