objective-c

How do I get the current access point's MAC address/BSSID?

My iPhone is connected to an access point through a WiFi connection. Does anybody now how I can retrieve this Access Point's MAC address with Objective-C? ...

Getting array elements with valueForKeyPath

Is there any way to access an NSArray element with valueForKeyPath? Google's reverse geocoder service, for example, returns a very complex data structure. If I want to get the city, right now I have to break it into two calls, like this: NSDictionary *address = [NSString stringWithString:[[[dictionary objectForKey:@"Placemark"] object...

Multiple Object Array Type?

Whilst learning Objective-C I ran into a situation where I needed to add two different objects (one inherits from the other) to an array. Whilst it does work I was not 100% sure it was good practice? @interface TireBasic : NSObject { } @end @interface TireSnow : TireBasic { } @end // To this array? TireBasic *tires[4]; cheers -gary-...

initwithint warning, no method found?

I have a warning and just can't work out how to make it go away. In my .h I have this... -(void)restartTimer; Then the in my .m I have... -(void)restartTimer{ TimerViewController *TimerView = [[TimerViewController alloc] initWithInt:hStart number:mStart]; I get this error: Warning: no '-initWithInt:number.' method found. I a...

NSTimer iPhone Question

I have seen a similar answer for my question but I would just make it clear. My Application needs sends an event to be fired even when the application is not active. I think it cant be done using a NSTimer. My question is that do I need to run the timer in some other runloop other than the main run loop to deliver the runloop, so that it...

Using Objective-C Blocks

Today I was experimenting with Objective-C's blocks so I thought I'd be clever and add to NSArray a few functional-style collection methods that I've seen in other languages: @interface NSArray (FunWithBlocks) - (NSArray *)collect:(id (^)(id obj))block; - (NSArray *)select:(BOOL (^)(id obj))block; - (NSArray *)flattenedArray; @end The...

How does one relaunch Finder programmatically?

If I ALT+RIGHTCLICK on the Finder icon, I get a "Relaunch" option in the context menu. I would like to programmatically relaunch finder, if at all possible. I'm sure there is a better way to do it than to just kill it and let it restart. Assume I have the proper authorization / permissions to do so already. Additionally, I would like...

How to determine the order of substrings in an NSString?

Hi, I wanted to know if there is any (easy) method to find the order of a given array of substrings in an NSString? I have a large block of text and a few substrings. I'm only interested in the order that the substrings first appear in the text. So if the text was "can you tell me you are working late if you can" and the substrings w...

How careful are you with your return types in Objective-C?

Say you have a method that returns a newly generated NSArray instance that is built internally with an NSMutableArray. Do you always do something like this: - (NSArray *)someArray { NSMutableArray *mutableArray = [[NSMutableArray new] autorelease]; // do stuff... return [NSArray arrayWithArray:mutableArray]; // .. or [[muta...

What are the most valuable parts of Computer Science studies for Cocoa developers?

What are the most valuable parts of Computer Science studies for Cocoa developers? Another way I might word this question is: If I’m not going to go to school for Computer Science but want to be a developer working primarily with Cocoa, what are the things I should make sure I learn that I otherwise might miss by being self-taught, an...

Objective-C syntax checker

Is there an Objective-C syntax checker? I have tried gcc -fsyntax-only but it is not really 'syntax only'. It still produces errors if run on an individual implementation file which has references to external frameworks. I am looking for something that can perform a syntax check on individual header or implementation files without att...

how to run my iphone 2.0 app in iphone os 2.0 and also 3.0 and above os

i have iphone with os ver. 2.0 i read that for app store all appplication must be run 3.0 os.so how could i make my application to run in both firmware.is there a way i can detect if os ver.>3.0 then run different statments alse run statments for lower than 3.0 os.currently i am using this. #if __IPHONE_3_0 cell.textLabel.text=cellValu...

Array Via Setter?

This is just a test to help me learn Objective-C, it uses NSMutableArray to add tire objects to an instance variable in a car object: // INTERFACE @interface CarBody : NSObject { NSMutableArray *tires; } // Should this be (id *) it works but I was convinced it would be pointer? - (void) addTire:(id)newTire; @end @interface TireSnow : ...

Securing xml plists in Cocoa / Objective C

I am writing an application which reads information from am xml plist in the bundle upon startup. The information in the plist has been compiled through many days of work and I would like to ensure that it cannot be extracted easily from the app bundle by another party after distribution. Is there any way to secure or encrypt xml plists...

NSInvalidArgumentException

Hello, I Am creating an iPhone application which displays an UITableView at the start with some text in the cells. When a user taps a cell it should transition to another view. When I run the application in the iPhone Simulator and click on a cell I get the following error: 2009-09-23 12:20:03.554 ZDFMobiel[751:20b] *** Terminating app...

Array of directories names as data source for NSComboBox

Hi, I have some problems to retreive folder names and send them as items for a ComboBox My actual code: NSError *errors = nil; NSString *pathForDirectory = @"/Folder/Folder/"; NSFileManager* fileManager = [NSFileManager defaultManager]; NSArray *contentsDirectory = [fileManager contentsOfDirectoryAtPath: p...

Does anyone know how I can get the "real" size of the UIImageView instead of creating a frame

Well my title kind of says it all I guess ..( at least I hope) I was hoping there was some sort of function that could take the real size of my picture CGRect myImageRect = CGRectMake(0.0f, 0.0f, 320.0, 210.0f); // 234 UIImageView *myImage = [[UIImageView alloc] initWithFrame:myImageRect]; [myImage setImage:[UIImage ima...

Reading data from a file

Hi, I'm new to mac and Cocoa so I'm sorry if this is a stupid question.. I need to read all the lines I wrote on a file I saved on my desktop. The file format is .txt; I tried with stringWithContentsOfFile but the program freezes. I tried with GDB and I noticed that, while the path is correct, the string which is supposed to contain the...

Handling nil exceptions in objective-c

Hey all I'm using a MPMoviePlayerController and trying to catch my exception when there is no movie present. movies = [movieDictionary objectForKey:@"movieID"]; NSLog(@"callVideoSetting"); CGRect playfram = CGRectMake(0, 0, 320, 500); stopButton = [UIButton buttonWithType:UIButtonTypeCustom]; [stopButton setFrame:playfram]; [stopButt...

NSMutableURLRequest timeout interval not taken into consideration for POST requests

I have the following problem. On a NSMutableURLRequest using the HTTP method POST the timeout interval set for the connection is ignored. If the internet connection has a problem (wrong proxy, bad dns) the url request fails after about 2-4 minutes but not with NSLocalizedDescription = "timed out"; NSUnderlyingError = Error Domain=k...