cocoa-touch

Create a cookie for NSURLRequest?

I'm trying to send an authentication string via cookie in a NSMutableURLRequest. I'm trying to create the NSHTTPCookie through +(id)cookieWithProperties:(NSDictionary *)properties But nowhere have I been able to find how to specify the properties other than the simple key-value pair I have for authentication. When I only use my key-v...

Is there an iPhone equivalent of MAC_OS_X_VERSION_MIN_REQUIRED?

I would like to conditionally include code for an iPhone app depending on which version of the SDK I'm compiling against. On Mac OS X, there is the MAC_OS_X_VERSION_MIN_REQUIRED preprocessor macro which gets set to the value of the MACOSX_DEPLOYMENT_TARGET build setting by the compiler. Is there an equivalent on the iPhone? Update: I...

How do I save current tab bar item when user quits and reload to that item when restart?

I want to save the current tab the user is in when he/she quits the application so I can load the application with that tab highlighted when the user re-enters the app. I presume I use the following method within my app delegate to save the current tab - (void)applicationWillTerminate:(UIApplication *)application but how do I gain acc...

Date problems

Hi! I would like to keep track of the date with timestamp. What objective-C/cocoa class could I use to get the timestamp local to the machine's time settings? if for example I'm in USA, timestamp should be in terms of the area where I'm at. If I'm in Europe, should be in Europe time. Small example would be so helpful! ...

UITableView scrolls to far and causes weird things

I have a UITableView that when scrolled to far bounces bag. This also means the user can drag the table so that only half of it is visible and the other half of the main view is white. This causes some weird behavior in my app. I create an array in the AppDelegate. In RootViewController's viewDidLoad, I get a reference to the AppDele...

NSString Compare Not Working in Objective-C

Following is Objective-C code where I'm trying to do a compare between two NSString values, however it throws a runtime error. Here's the code: NSDictionary *innerContent=[JSONResponseDict valueForKey:@"JSONRESPONSE"]; NSString *authFlag = [innerContent valueForKey:@"authenticationFlag"]; NSLog(@"authFlag = %@",authFlag); UIAlertView ...

Creating an iPhone library/framework

Are there any tutorials describing how to create a library or is it framework for the iPhone? I have a number of methods that are shared between applications. These will be better maintained as a library. ...

Accessing data member of RootViewController in another class

I am developing an iPhone application using Objective-C. I want to access a data member which is of type NSMutableArray of the RootViewController class in another class. I tried making the array static. But I would like to have a non static array. How do I achieve this? ...

Testing use of NSURLConnection with HTTP response error statuses

I'm writing an iPhone application that needs to get some data from a web server. I'm using NSURLConnection to do the HTTP request, which works well, but I'm having trouble unit testing my code in the case where the response has an HTTP error code (like 404 or 500). I'm using GTM for unit testing and OCMock for mocking. When the server ...

Passing a value from one object into another with Objective-C

I have a class called GameScene, with is a subclass of a cocos2d Scene. In there I have two layers. GameLayer and ControlsLayer. You can probably tell already that I want the ControlsLayer to move stuff around in the GameLayer. To be precise, I'm trying to control a cPBody in the GameLayer from the ControlsLayer. At the moment, I'm t...

Determining speed of shake

Is it possible to determine the speed at which someone is shaking their iPhone? This would be the time they start moving to the ending point where they are now going back to the origin. Basically it is one swipe that I'd like to measure the speed of. This discussion comments on initial speed: http://discussions.apple.com/message.jspa?...

Take picture with iPhone API and transfer it to a server

Hi, I have written an cocoa application to take a picture on the iPhone. I need to transfer the images taken to somewhere besides the iPhone namely another server. Does anyone know how I can accomplish this? Thanks, Joe ...

Interface builder added one tab bar button, but not showing up.

I replaced one tab bar button in interface builder. It was "Recent" button, I changed it to "Contacts" button. Now the tab bar button not showing up, but I could click on that position, and action does work. The neighbor unchanged tab bars have no problem though. I could not find any place to set the visibility of Tab Bar button. Than...

How do I time a Cocoa app?

What is an easy way to time a Cocoa application? (Alternatively, any good way to measure performance would suffice). (I have two different frameworks and would like to compare their performances over some fixed input data) ...

Cocoa Touch table datasource problem

I'm having some trouble with displaying results from a datasource. This code will show a different (and correct) result in the console, but results in all kinds of random crap in the simulator. ("results" is an NSMutableArray property for the class.) -(void) handleSearchForKeywords: (NSString *) keywords { [results removeAllObjects...

Add cocos2d menu items at run-time

I am trying to add a variable amount of MenuItem objects to a Menu object on runtime. When my game starts I don't really know if my menu is having 2 or for example 5 items. for (MyItem* item in myItemCollection) { MenuItemImage* menuItem = [MenuItemImage itemFromNormalImage:@"MenuItem.png" selectedImage:@"MenuItemSelected.png" targ...

Can you tell UIWebView to use a white indicator style?

I'm running into a case where I have in-application HTML documentation that uses a dark background, but the default scroll indicator for UIWebView is getting lost in that background. The following is an example of this: With UIScrollView, which UIWebView resembles in its behavior, you can set the indicatorStyle property to UIScrollVi...

iPhone Cocoa hyperlink

Hi, is there a way to display a hyperlink in an iPhone native app. Is this done with a label or another UI object? Thanks! Joe ...

How can I prevent iPhone NSNumberFormatter from rounding?

Hi, I'm trying to format large currency numbers like this: NSNumber *testVal = [NSDecimalNumber decimalNumberWithString: @"999999999999999993.00"]; NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init]; [formatter setNumberStyle:NSNumberFormatterCurrencyStyle]; [formatter setMaximumIntegerDigits:19]; [formatter setMaximumFract...

Convert a Cocoa Touch latitude/longitude to a string without degree symbol

I'm trying to convert CLLocation latitude / longitude to a string. I can successfully do this with the follow code: // extract latitude from CLLocation object and cast to string NSString *latitude = [[NSString alloc] initWithFormat:@"%g°", location.coordinate.latitude]; this gives me a value like: 34.10111º. I would like this number...