objective-c

Is it possible to change the root view of a tabBarItem so tapping takes you to the second view in the hierarchy?

In Obj-C / iOS. Our UI design calls for an initial screen with options to register or log on. After doing either of these, the user data is saved to the phone and a the tabBarController is shown. However, tapping on the tabBar at the bottom takes the view back to the "log on or register" screen. Is it possible to change the root view con...

UISlider sender valuechanged

Hi, I'm using multiple UISliders on a form, and I want just one method to keep track of slider changes. Now I have a method: - (IBAction) slider1ValueChanged:(UISlider *)sender { somelabel.text = [NSString stringWithFormat:@" %.1f", [sender value]]; } But because I use multiple sliders, I want to use a switch statement to fi...

Add row in a TableView.

Hi, So I have two views, the first have my TableView and the second have my TextField and I want to add a row in my TableView with the text in my TextField. For the moment I can just add row with [myTableView addObject:@"Test 1"]; [myTableView addObject:@"Test 2"]; [myTableView addObject:@"Test 3"]; Thanks for your help! - (UITab...

How to apply a solid color to a UISearchBar

I saw this post on SO: http://stackoverflow.com/questions/2232016/uisearchbar-solid-color But no answer was provided. I would like to know how to apply a solid color to a UISearchBar. I have applied a tintColor but it automatically creates a gradient. ...

NSDate from NSString problems

Getting a NSString as follows: NSString *lastSyncDate = [[items objectAtIndex:0] objectForKey:@"LastSyncDate"]; This value is: 1/1/2010 12:00:00 AM I am using the following to convert to a date: NSDateFormatter *df = [[NSDateFormatter alloc] init]; [df setTimeStyle:NSDateFormatterFullStyle]; [df setDateFormat:@"MMMM d, y HH:mm:ss ZZ...

Objective C - #define vs const vs static

Hi, What is the best way to define a globally accessible string? I see that for integer it's usually like this #define easy 0 However, how can I emulate that for NSString? I tried static NSString *BACKGROUND = @"bg.png"; While that work, it does give a warning saying the variable is never used. (I have all these in a .h file) Doing...

In Objective-C Determine if a Property is an int, float, double, NSString, NSDate, NSNumber, etc.

I need to determine an object's property (passed by name) type in order to perform deserialization from XML. I have some general pseudo-code (however I am unsure of how to perform these comparisons in Objective-C): id object = [[[Record alloc] init] autorelease]; NSString *element = @"date"; NSString *data = @"2010-10-16"; objc_proper...

Does UIGestureRecognizer Work with UIWebView

I am trying to get a UITapGesture Recognizer to work with a UIWebView. I want to be able to detect when a button is pushed on my web view. If i set the userInteractionEnabled property of the webview to NO it works, it also works if numberOfTouchesRequired is set to 2. How do i detect touches and the position of the touch in a UIWebView?...

Nice book/tutorial about using UDP in objective c?

Hey, I wanna make a MMORPG, I'm now working on the multiplayer. The client is iOS device, so I'll use objective c on the server too. I'm googling for hours and can't find a nice tutorial to use the UDP for begginers. Also is obj-c on the server is a good idea? Oh, and other thing.. What is "Socket"? Thanks! ...

How would you debug this iphone bug

-[CFString respondsToSelector:]: message sent to deallocated instance 0x4b9e720 I don't where to start, tried static analyzer and stepped through each line of code but still no help. ...

Intercept obj-c delegate messages within a subclass

I have a subclass of UIScrollView that I need to internally respond to scrolling behaviour. However the viewcontroller will still need to listen to scrolling delegate callbacks so I can't outright steal the delegate within my component. Is there a way to keep the property named "delegate" and just listen to messages sent along it, or els...

Float value evaluation completely incorrect

Hey internets. I am having a VERY strange issue in C. I am deriving a float value, and then checking to see if it is greater than 0. However, the comparison is always evaluating to true, even if the value is less than zero. Here is the code: if (sVel > 0.0f) { sVel += 1.0f; sVel -= 1.0f; NSLog(@"SEP VEL: %1.6f", sVel); ...

Cocos2D - AtlasAnimation doesn't work when looping once

Hi, How do I control the speed & flow of an AtlasAnimation? I have the code below AtlasAnimation* animation = [AtlasAnimation animationWithName:@"anim" delay:0.1]; [animation addFrameWithRect:CGRectMake(0, 0, 87, 87)]; [animation addFrameWithRect:CGRectMake(87, 0, 87, 87)]; [animation addFrameWithRect:CGRectMake(174, 0, 87, 87)...

MFMessageComposeViewController alloc returns nil

In my application, MFMailComposeViewController works fine but creating a new instance of MFMessageComposeViewController fails. Here is the code for both: -( IBAction)sendSMS: (id)sender { MFMessageComposeViewController *picker = [[[MFMessageComposeViewController alloc] init] autorelease]; picker.messageComposeDelegate = self; NSAr...

OCUnit wants me to install Rosetta

I followed the instructions on Unit Testing objective C from Apple: http://developer.apple.com/tools/unittest.html I installed the latest version of OCUnit, but when I compile, software update starts and tells me I need to install Resetta. What's going on? ...

How to upload file through objective C?

Hi, everyone, I want to ask a question about the objective C on iPhone. I want to upload a file (actually I store all the data in a NSString) to a server. However, I have not idea of how to do, I have checked the website of the Apple Developer, and I know there are a function called connection:didSendBodyData:totalBytesWritten:totalByte...

How should I get this Objective-C object into a local file?

I've got an iPhone app that loads a bunch of TableViews. The first time a user loads the app it downloads .json from a remote server, parses that into a NSDictionary and saves it locally on the device as a .plist. Unfortunately, I can't figure out how to do a reloadTable on the MainWindow.xib after the data loads, so it sits blank until...

What does this ^ syntax mean in Objective-C ?

In iPhone SDK 4.0 UIApplication has a new method, setKeepAliveTimeout that requires a second parameter of type 'void(^)(void)'. -(BOOL)setKeepAliveTimeout:(NSTimeInterval)timeout handler:(void(^)(void))keepAliveHandler What exactly does the syntax of the second param mean, and how would I declare a function/handler that I can pass into...

Need help in finding a memory leak in copying Sqlite Database to Mutable array.

I seem to be having a 1.19 KB leak somewhere in the following code. opening up the call tree in instruments, I have narrowed down the leaks to the following: 61.8% of the leaks are coming from +[NSString stringWithUTF8String:] 38.1% of the leaks are coming from +[NSNumber numberWithDouble:] -(void) readMinesFromDatabase { NSLog(@...

music application in iphone interruption handle

I try the code to avoid the sleep mode interruption it's working but now I have the problem with interruption when call or sms is coming on iphone the song is stop ok at that time.Where the song is stop i want to start the song automatically when the call is end. - (void) audioPlayerBeginInterruption: (AVAudioPlayer *) player { if (pl...