objective-c

Do I need to release NSString generated using @"..."?

If I make an NSString using the code below, do I need to need to release someString? NSString *someString = @"somestring"; ...

Is there any way to pass an NSArray to a method that expects a variable number of arguments, such as +stringWithFormat:

Some context: I'm trying to clean up some of my FMDB code. My one table has a lot of columns and the method in FMDB I need to use is one that expects a variable number of arguments, similar to NSString's class method +stringWithFormat:. An example: [db executeUpdate:@"insert into test (a, b, c, d, e) values (?, ?, ?, ?, ?)" , @"hi'", /...

iPhone app using openAL works in simulator, but not on device

I added the openAL framework to my app and I am using the sound engine that is in the demo CrashLanding. It works just fine on the simulator, but when I build it for my device, I get errors. It looks like the framework isn't added. I've tried: restarting xcode; delete the framework and add it in again; cleaning the target; restart the...

converting strings to enumerated types

Does anyone know how to (or if) you can convert a string to an enumerated type in the objective-c/cocoa/iphone environment? For example: If I have an XML document with the element: <dog breed="GermanShepard"> I would like to be able to read the "breed" attribute into an NSString and then convert it into a type "Dogs" as defined here:...

nearest WiFi station MAC address

I want to find nearest WiFi station MAC address in iphone programatically. So can any body help me for that? ...

Why does using dot-syntax invoke the LHS of this statement twice?

This test will fail: #import "GTMSenTestCase.h" @interface Person : NSObject @property (readonly) NSString *name; @end @implementation Person - (NSString *)name { return @"Nick"; } @end @interface TemplateUnitTest : GTMTestCase @end @implementation TemplateUnitTest static BOOL called = NO; - (Person *)get { if (called) { STFail(ni...

NSArray initWithObjects: not loading

As a test, I'm doing the following as the first line in applicationDidFinishLaunching: NSArray *list=[[NSArray alloc] initWithObjects:@"Andy",@"Erik",@"Aaron",nil]; After the line runs, I have zero objects in the array. I'm doing this further down the code path but wanted to eliminate any influence to make sure my syntax is correct. ...

Problem storing objects in NSMutableArray

I'm developing on the iPhone and I'm missing something about storing objects in an NSMutableArray - what am I doing wrong and how should I approach this? The relevant sections of the code are I have an object, Entity, defined which inherits directly from NSObject. In my class GLView I wish to define an array of these - so GLView.h @...

how to determine WiFi signal in iPhone

iPhone can determine WiFi station in network? And also MAC address for that WiFi station i want to retrieve. So can u help me? ...

is it possible to go rootViewController page from any page in objective c?

Hi! i am trying to build an iphone app. I am trying to build it at View based application. suppose i have gone to y.xib file from x.xib nib file. and x.xib nib file has been come from root.xib file. i would like to go root.xib file from y.xib, How? ...

Objective C class definition confusion

I'm learning Objective-C through Cocoa (And loving it). I'm following a tutorial. Theres a class called Menu and the interface looks something like this. @interface Menu: MenuObject {} @end @interface MenuLayer : LayerObject {} -(void) someMethod:(id)sender -(void) someOtherMethod:(id)sender @end and the implementations follow the s...

SHA1 hashes not matching between my Rails and Cocoa apps

I have a Cocoa app send some data along with a SHA1 hash of that data to a Rails app which verifies that the data and the hash match, but they do not. To be sure I have logged hex versions of the data that is hashed to the console at both the Rails and Cocoa sides, and they match exactly. Here's the Cocoa part: #import <CommonCrypto/C...

How to cast an object in Objective-C

Is there a way to cast objects in objective-c much like the way objects are cast in VB.NET? For example, I am trying to do the following: // create the view controller for the selected item FieldEditViewController *myEditController; switch (selectedItemTypeID) { case 3: myEditController = [[SelectionListViewController alloc...

Why does Objective-C use YES and NO instead of 1 and 0?

Is there any technical reason why Objective-C uses YES and NO instead of 1 and 0, or is it simply to make it more readable? ...

Making an NSTextField act like a "microwave timer", store as NSNumber

What I'm trying to accomplish is two fold: I want my NSTextField to act like a "microwave timer" and update as characters are entered. So the field would default to "00:00" (minutes, seconds). When a 1 is pressed, the field would look like "00:01". Then a 4 is pressed and "00:14". A 2 is pressed and "01:42". I want to store this as an ...

How to draw a line with Cocos2d-iPhone

Hi all, I'm trying to get to grips with Cocos2d by trying to accomplish simple things. At this point, I have a scene, that scene has a background sprite, and a Layer. I'm trying to draw onto the Layer uding drawLine. Here's by current attempt. @implementation MyLayer -(id)init{ self = [super init]; if(self != nil){ glColor...

In obj-c/iPhone SDK how do I get a mthod to call itself?

I have a method that I need to repeat until a certain condition is met. I am using an statement like: if (condition is not met){ run this method again } else { } But I don't know how to 'run this method again'. The method is called runAction so i tried [self runAction] but it caused a runtime error. Any help appreciated. Thanks ...

Objective-C memory management--best practices when returning objects?

Suppose I have a function like this: - (NSSet *) someFunction { //code... return [[[NSSet alloc] initWithObjets:obj1, obj2, nil] autorelease]; } When I call this function, do I need to do retain/release the return value? I'm assuming I do. However, what if I don't do autorelease, so someFunction now looks like this: - (NSSet...

In NSMutableArray methods, removeObject: vs removeObjectIdenticalTo:

With regards to a NSMutableArray, what is the difference between removeObject: and removeObjectIdenticalTo: The wording in the API Reference seems very similar: rO: Removes all occurrences in the receiver of a given object rOIT: Removes all occurrences of a given object in the receiver What am I missing? UPDATE: I mean,...

How to parse nested JSON objects with JSON framework and Objective-C/iPhone/Xcode?

I'm writing an iPhone native app using the JSON framework. My app is accessing web services using JSON. The JSON data we send has nested objects, below is an example of the data served up: {"model":{"JSONRESPONSE":{"authenticationFlag":true,"sessionId":"3C4AA754D77BFBE33E0D66EBE306B8CA","statusMessage":"Successful Login.","locId":1,"us...