objective-c

How to swap two numbers without using temp variables or arithmetic operations?

This equation swaps two numbers without a temporary variable, but uses arithmetic operations: a = (a+b) - (b=a); How can I do it without arithmetic operations? I was thinking with XOR ...

iPhone Development and NSStrings help

Hi, I would like to make a linked word that a word will be marked and when the user touch this word, it will open a link. How can I do that? Thanks! ...

Having trouble copying data to a mutable array

I keep getting the error "Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[MainViewController minimalFormInContext:]: unrecognized selector sent to class" from this line of code: NSLog(@"Accessing specific mine entities"); NSEntityDescription *entity = [NSEntityDescription entityForName:@"Mine" inMa...

Creating an array of custom objects in Objective C

EDIT What i am trying to achieve with the code, is to create an array of 20 unique 'Person' objects. I know now thanks to the guys below that i am going way off calling dealloc. for (int i = 0; i < 20; i++) { Person *myPerson = [[Person alloc] init]; myPerson.name = @"Brian"; myPerson.age = [NSNumber numberWithInteger:23]; ...

question about reading data from urls on iphone/ipad

I have an app which uses a UIWebView to load a webpage, I then parse the links (triggered by a call of webViewDidFinishLoad) from that webpage and load all these html files using NSString initWithContentsOfURL. This works, but it takes forever to load the links... even tho I've clocked how long each initWithContentsOfURL call takes and t...

Objective C syntax inside .cpp file?

I'm trying to copy over some example code into my own project. The example project is iPhoneExtAudioFileConvertTest from the sdk. The example project contains a file called ExtAudioFileConvert.cpp. This file contains what looks like Objective-C code: assert([NSThread isMainThread]); The example project runs fine, but the compiler comp...

A method to override that gets called a couple of times a second? or a loop its safe to code into?

Hi guys, Making a simple card game, and it it should ok when the user is in control since he will push a button. It will call my method assigned to that button and logic will be performed and screen updated. But when the players turn ends, and i want the AI to run everything for a few seconds, update the screen with its decisions etc. ...

How to subclass the NSObject while getting rid of -(id)init?

I want a class that take a REQUIRED argument like the UITableViewController that does not have init. Currently I just throw an exception when invoking init. Is there a way to deactivate it completely? ...

EMKeyChain Problems

I want to store the FTP Password in a Keychain rather than in the NSUserDefaults. So I used a wrapper called EMKeyChain to store the problem. The problem being is that it won't load the password when the Preference Window is loaded: Note: FTPPassword is a IBOutlet for NSTextField in PreferenceController.h -(void)windowDidLoad { //Check...

Objective C parse hex string to integer

I would like to know how to parse a hex string, representing a number, in objective c. I am willing to use both an objective, or a C based method, either is fine. example: #01FFFFAB should parse into the integer: 33554347 Any help would be appreciated! ...

Simple Memory Management Question In Objective-C

There's a memory leak in my program and because I'm not well versed in C (created a function in my Objective-C class to load strings from a SQLite database). Can anyone spot my blunder? Thank you: static int MyCallback(void *context, int lCount, char **values, char **columns){ NSMutableArray *sqlRawStrings = (NSMutableArray *)context; ...

What's the best way for a ViewController to communicate to his model?

I'm currently relying on the fact that UIApplication is a singleton and I access the models as delegate's properties, but that seems a long chain to me. Controller->UIApplication->delegate->Model (->particular property to be set) ...

save and restore an array of custom objects

I have an NSArray of custom objects that I want to save and restore. Can this be done with NSUserDefaults? ...

GC on unregistered thread in a Core MIDI callback

Hi, I am just getting started again with Mac development. I am using CoreMIDI which is a C API which allows me to define a C callback function to be called from the MIDI server on a separate thread whenever a MIDI message arrives. The registration of this callback is done in Objective-C/C code triggered by an awakeFromNib call. It see...

iPad Obj-C Sketch Application Slow Performance

Hey everyone, I'm trying to whip up a sketch application for the iPad so that I can draw with my finger. I've got a problem that the performance is atrocious. I've pasted a snippet of the core of my code below. In reality it's a bit more complicated. Does anyone know off the top of their heads why this CGContext stuff is slow? I'd appr...

iphone hide UISearchDisplayController results?

I currently have a UISearchBar and UISearchDisplayController implemented as: - (void) viewDidLoad { videoList = [[NSMutableArray alloc]init]; //Add the search bar aSearchBar = [[UISearchBar alloc] initWithFrame:CGRectZero]; [aSearchBar sizeToFit]; aSearchBar.delegate = self; aSearchBar.placeholder = @"Search YouTube..."; ...

How to get GeoCoordinates from pictures in iPhone

Hi, I am developing an application which picks photo's from photo library using UIImagePicker. I want to read the geo-coordinates of the photo and use them in my application. Can you point me to any example code on how to do that ?? First of all is it possible to that ?? Any pointers to which classes I should use ?? Regards HIte...

Loading screen while UITableView performs "tableView:heightForRowAtIndexPath:"

I am using tableView:heightForRowAtIndexPath: to set a custom height for each table cell in a UITableView. This is an expensive operation but I have not found a way to speed it up yet (In the future I will be trying some of the methods mentioned by taber). For now I would just like to display a loading screen of some sort. it does not n...

Objc memory crash with autorelase

I have been hunting all over my code and can't find the source of this crash: I am trying to decode an object with an NSKeyedUnarchiver and it crashes on it every time and says: *** __NSAutoreleaseFreedObject(): release of previously deallocated object (0x1008ad200) ignored *** __NSAutoreleaseFreedObject(): release of previously deallo...

Will my iphone 3gs app work ok on iphone 4?

So I'm currently making an app that supports both iphone 3gs and ipad (this is a universal binary app). What I'm wondering is how will iphone 4 users view my app, will they see it pixelated? will they not see it full screen since my iphone 3gs is on a smaller resolution? I don't have an iphone 4 yet but I'd rather just release this app...