objective-c

Thread safe static variables objective c

Is there a way in objective C that I can define a static int that is thread safe? for example if I have class called Session that has: static unsigned int session_id = 1000; - (int) generateSessionID{ return session_id++; } I am constructing session objects from different threads, each session object should have a unique id...

How to put text on different lines in a table cell

In a table cell I tried putting "\n" in the text, but this doesn't put the text on a new line it just puts a space in between the text. ...

How to get UIButtons title in an array to be shown each one by one in a timed sequence

In my program, I have a series of UIButtons in an array that I would like its title to be shown each one at a time one by one in a timed sequence after executing a function that has a while loop. I have an IBAction attached to the buttons and when touched will call another function that will do some operation and in the end, will chang...

Objective-C Iterating through an NSString to get characters

I have this function: void myFunc(NSString* data) { NSMutableArray *instrs = [[NSMutableArray alloc] initWithCapacity:[data length]]; for (int i=0; i < [data length]; i++) { unichar c = [data characterAtIndex:i]; [instrs addObject:c]; } NSEnumerator *e = [instrs objectEnumerator]; id inst; while (...

NEED HELP,Objective C strange parameter

Hi All: I am a Iphone freshMan today a wired parameter confused me, - (UIBackgroundTaskIdentifier)beginBackgroundTaskWithExpirationHandler:(void(^)(void))handler /* ... */ bgTask = [application beginBackgroundTaskWithExpirationHandler: ^{ dispatch_async(dispatch_get_main_queue(), ^{ [application endBackgroundTask:self->bg...

Does calling a protocol method pass program flow control?

I know this is quite possibly a lame question, but I've pulled three consecutive all-nighters and I'm very blurry. And I'm new to Objective C and Cocoa Touch. I've created a class that provides a delegate method. I'll use simplified example code since the specifics aren't important. The header file looks like this: #import <Foundation/...

sqlite foreign key in iphone sdk

hai guys, i am planning to create a table view and the detail view for the corresponding row, all the datas are fetch from the sqlite database. For this i have created two tables in the database table one for the datas in the table view list and table two for the detail view of the table list. i set the product id as the primary...

UITabBarControllerDelegate methods not gettning invoked

I have a tabbar based iPhone app, I have set the delegate for tabbarcontroller, but for some strange reason the delegate methods are not getting invoked. ...

Accessing Uislider from another view..

Guys... How can i change the .alpha value of UIslider from another view... i have also tried using appdeligate like this :- MyAppDelegate *appDelegate = (MyAppDelegate *)[[UIApplication sharedApplication] delegate]; appDelegate.viewController.sliderIncreaseWidth.alpha=1.0; but the value is not changing... I hav also tried to call a...

Why retainCount returns value after release being called?

Hello, I have the following simple piece of code: NSMutableArray *array = [[NSMutableArray alloc] init]; NSObject *o = [[NSObject alloc] init]; NSObject *o1 = [[NSObject alloc] init]; NSObject *o2 = [[NSObject alloc] init]; [array addObject:o]; [array addObject:o1]; [array addObject:o2]; NSLog(@"-------");...

Semantics of Objective-C Methods

Coming from a Java background, I'm still don't quite understand the semantics of Objective-C methods as opposed to their syntax. Take as an example the following method: - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView; Easy enough. There is a method named numberOfSectionsInTableView which takes a UITableView as a par...

How to upload video to favorite/playlist using gdata in objective c

hi, i am trying to upload a video to favorite in my account but it shows Invalid request Uri and status code =400 i dont understand how should i format my request my code NSURL *url = [NSURL URLWithString: http://gdata.youtube.com/feeds/api/users/username/favorite]; ASIFormDataRequest *request = [ASIFormDataReques...

universal application ipad/iphone image naming convention?

Hi In my application i need to get the correct image based on the device ipad/iphone4/iphone3 device. for example i have image name a.png(width 40,height 20) its for iphone3/ipod ,and if i give [email protected] (width 80,height 40) its for iphone4 , if i mentioned the code UIImage *myImage=[UIImage imageNamed:@"a.png"]; myImage contains...

How can I add the following extra linker flags?

To support OS 3.x, please set Base SDK to iPhone Device 4.0 and iPhone OS Deployment Target to iPhone OS 3.x. Extra linker flags may be needed if NSConcreteGlobalBlock and UIBackgroundTaskInvalid runtime error occur under 3.x. The linker flags are: -weak_framework UIKit -weak_library /usr/lib/libSystem.B.dylib EDIT: im still getting th...

The 'rootViewController' outlet of UIWindow is not available on releases prior to iOS 4.0

I am getting the following error on pre-iOS 4.0 builds: The 'rootViewController' outlet of UIWindow is not available on releases prior to iOS 4.0. Remove the connection and instead programmatically add the view controller's view to the window after the application finishes launching. How and where do I do this programmatically? ...

How to delete calendar events faster?

Following code works and deletes all calendar events from iPhone calendar database. But events are deleting very slow: 2 events per second on iPhone 3GS. So if you have 3000 events - then it's 25 minutes to erase them... How would you optimize this code? Maybe I am doing something wrong? Thanks. - (void)deleteAllCalendarEventsFromIPho...

Best XML parser 4 iPhone? Best way to parse a XML Document 4 iPhone?

Hi, I need to parse a XML and then print it in a tabla view. Someone who can help me. Explain me about parsing or giving me documentation? Whatever... By the way i'm using a parser class, that I don't understand much... that works in iPhone Simulator but don't works in my device. I don't know why... Thank you so match. Any help will be...

Left Call Out View is not working in 3.0, 3.1, 3.1.3.... but it is working in 4.0....

Hi Guys, I have got some problems in MapKit, that is leftCalloutAccessoryView is not working in 3.0, 3.1, 3.1.3 but it is working in 4.0 Can please suggest any solution for this. Thanks, Madan Mohan. ...

cocos2d animate

I try create animation in my application written on cocos2d. I make it on this tutorial http://getsetgames.com/tag/ccanimation/ All work fine. But I write all code in my Engine class. Also I have class for object which I would like animate. And I have special class for create object. Now I try next File which must have animation sprite...

Convert a NSTimeInterval duration into NSString

Hello all, I am new in iphone development. I have a issue. I want to convert a NSTimeInterval value in NSString, but not success in this. please a quick look on below code. in .h NSTimeInterval startTime; NSTimeInterval stopTime; NSTimeInterval duration; in .m startTime = [NSDate timeIntervalSinceReferenceDate]; stopTime = [NSDate ...