objective-c

round double in objective c

I have double number in a format like 34.123456789. How can I change it to 34.123? I want just 3 digits after the decimal point. ...

Identifying an object name by appending a generic name with a changeable value. Is this possible?

Say I have 5 UIImageViews, named image1 image2 image3 image4 and image5. And I have 5 buttons, which have their tag values set to the corresponding images that overlay them, so 1 - 5. If button 1 is pressed, I get the tag value like so NSNumber buttonNumber = [sender tag]; I then want to perform some methods on the corresponding...

How to perform sequential file write in separate thread

I am given some data in a callback function to write to disk sequentially, about 4KB every 0.02 seconds. If I fwrite() from the thread the callback function is in, I get some lag in other parts of code in same thread. So in order to not block this thread while writing to disk, I want to move the fwrite code to another thread. The problem...

UITableViewController detailView never pushed

I have a UITableViewController as one of the view controllers on the second tab of my tab bar controller. In didSelectRowAtIndexPath i create a detail view controller, but it never gets pushed onto the navigation stack... and the app doesnt crash either, as i can NSLog after the call to pushViewController. This is the method: - (void)...

NSString - replacing characters from NSCharacterSet

Hi Everyone, I gotta little question about string Programming: I have an NSCharacterSet which contains all the characters I want to remove from my NSString. How can I do that? Thank you, Christian ...

Split strings error whats wrong with it

//Seperate into arrays NSString *NumberItems = [RawMessage componentsSeparatedByString:@"|"]; //Create the strings NSString *number1 = [NumberItems objectAtIndex:0]; NSString *number2 = [NumberItems objectAtIndex:1]; NSString *number3 = [NumberItems objectAtIndex:2]; NSString *number4 = [NumberItems objectAtIndex:3]; NSString...

Code problem - objective c - waiting for string value to appear in string value

task = [NSTask new]; [task setLaunchPath:@"/bin/sh"]; [task setArguments:[NSArray arrayWithObject:@"/applications/jarvis/brain/server.sh"]]; [task setCurrentDirectoryPath:@"/"]; NSPipe *outputPipe = [NSPipe pipe]; [task setStandardInput:[NSPipe pipe]]; [task setStandardOutput:outputPipe]; [task launch]; NSMutableString *outputString =...

Problem in inserting data in SQLite?

Hi i am using FMDB to retrieve data from SQLITE database. db = [[FMDatabase alloc] initWithPath:path]; [db open]; FMResultSet *fResult= [db executeQuery:@"SELECT * FROM Users"]; aUsers = [[NSMutableArray alloc] init]; while([fResult next]) { userData = [fResult stringForColumn:@"Name"]; lblUsers.text=[lblUsers.text...

Configuring log4Cocoa

Hello. Im trying to configure the log4cocoa framework to log as DEBUG level messages to the console and INFO level to some file.I cant figure out how it's done. I have not found any documentation about it, what make things even harder. This is an example of configuration I`ve tried (not working): log4cocoa.rootLogger=DEBUG,A1 log4coc...

How to get the favorites list from the address book in Iphone sdk?

Hi Guys, I need a help from your side as I am new to iPhone sdk. Actually I need to access the favorite contacts in the Iphone to my application. Can any one suggest me how to access the favorite contacts list in iPhone. Thanks in advance, Monish. ...

problem in creating - Provisioning Portal.

i'm trying to create an In-App purchase. but i'm facing a problem in creating - Provisioning Portal. After creating an APP ID, On the “Configure App ID” screen, i'm unable to get that option “Enable In App Purchase”. what could be the possible error i'm making in the procedure ? ...

Formatting Characters

I have an application (IM Client) that I wish to setup custom formatting symbols in similar to mIRC rather than relying on rich text. I will accomplish this by pairing a UniChar 003 with a number 0-15 to process colors and other characters for different things. The only problem that I have is that when these characters are inserted they ...

objective-c programmatically change table view from standard to grouped?

Hello all, The following situation pertains to an iPad app I am working on for my company. So I have an array of type "Person" that holds the information of a list of people. On the initial page, I have a table that displays their name and picture. When this loads, the results are ungrouped. I was wondering if there was a way to eas...

iOS 4 VOIP app responding in the background

Hi there, I have an iPhone VOIP app that copes with multi-multi transmit and receive (ie teleconferencing) set up using BSD sockets. I would like it to be able to respond to incoming requests when it is in the background but from what I can understand of the iOS 4 docs I can only do this on an NSStream object (or CFRead/WriteStream) by...

Best time to invalidate NSTimer inside UIViewController to avoid retain cycle

Does any one know when is the best time to stop an NSTimer that is held reference inside of a UIViewController to avoid retain cycle between the timer and the controller? Here is the question in more details: I have an NSTimer inside of a UIViewController. During ViewDidLoad of the view controller, I start the timer: statusTimer = [NS...

iPhone 4.0 OS, blocks

In my iOS adventures, I got really into blocks, because they were necessary for the UIViewAnimation to "Animate With Blocks" which is the recommended way to do UIView animations. Of course, this results in code that is not backwards compatible. I realize this question has a subjective component, but at what point would using the iOS 4.0 ...

Key Value Observing with an NSArray

I've looked on SO for examples of using Key Value Observing with an NSArray (or NSMutableArray) and apparently you need to use an NSArrayController (which unlike KVO I'm not familiar with), but I haven't found concrete examples of how to do this... can anyone explain with some sample code? For instance, if I have a GameModel which repre...

Doing [obj release] on obj with retainCount=1 does not decrement retainCount to zero

Hi, I created a simple program to test the retain/release methods in Objective-C memory management. As I understand of ObjC memory management, I expect that a object with retain count = 1 on which I call release get the retain count decremented to zero and then released. But this test program show that after the first release I still ge...

Handling Text Input with an iPhone's Virtual Keyboard

Hey Everyone, Does anyone know of a way to utilize the iPhone's hardware keyboard with something other than a UITextView/Field, basically I want to be able to send characters pressed on the virtual keyboard to my own view. If anyone can help me out that'd be immensely appreciated!! ...

Movable UIViews, like Tangram

In my iPad application, there is one main view. It contains various views which have different sizes and different images (tetragons, but not rectangles). The grey lines represent the frames, the red lines represent the outline of the image. It is a bit like Tangram, but more complicated since the tetragons are not rectangles. The vi...