objective-c

Address Book picker memory usage mystery in iPhone 3.0 project

Hello, I am getting email addresses out of the Address Book from a Cocoa Touch project and getting some unexpected results in terms of memory usage. The user opens the ABPeoplePicker and if the AB entry they touch has a single email address or no email address it uses (BOOL) peoplePickerNavigationController:(ABPeoplePickerNavigation...

How to dismiss UITableView?

My app pulls up a uitableview screen when the user clicks a settings button. I can't figure out how to wire up the request to dismiss with the action. How do I dismiss this view from within the uitableview? Setting up view: SettingsController *rootViewController = [[SettingsController alloc] initWithStyle:UITableViewStyleGrouped...

Reading letters from a custom iPhone keyboard

Hi, I'm trying to build an app that is a code breaking puzzle for the user. I've followed sample code on how to add a decimal to the numeric keypad and it works great. I would like to expand this so the whole keyboard is filled with custom images. Is it possible to have a piece of code that when the user presses on a symbol the iPhone...

what is retain count in objective c?

in my application i have a uitableview as my first screen with uinavigation controller. in my first screen i put NSLog(@"Home Screen retain Count=%d",[self retainCount]); in it's view did load it shows 6.is it correct or it is there is something wrong with this? ...

Using Core Animation/CALayer for simple layered painting

I would like to create a custom NSView that takes a layered approach to painting. I imagine the majority of the layers would be the same width and height as the backing view. Is it appropriate to use the Core Animation classes like CALayer for this task, even though I don't expect to need much animation? Is there a more appropriate appr...

Returning an array in cocoa, but waiting for delegation to complete

I have created the following method in cocoa: -(NSArray *)latestData { NSURL *requestingURL = [NSURL URLWithString:@"someRestfulURL"]; NSMutableURLRequest *theRequest =[NSMutableURLRequest requestWithURL:requestingURL]; [theRequest setHTTPMethod:@"GET"]; NSURLConnection *theConnection = [NSURLConnection connectionWithR...

How to select a UITextField?

I want to edit the user's username inside a UITableView. I added a UITextField to the UITableViewCell and this seems to work very nicely. But when the user touches the cell (even outside the textfield), he expects to edit. How do I programatically select the textfield? The code would look something like: - (void)tableView:(UITableVi...

How does hiding a UIStatusBar apply to UIViews being shown?

I have a mostly-navigation-bar-driven application. A few cases require the presentation of a modal view, and one of those cases requires the hiding of the status bar. However, even if I hide the status bar before presenting the modal view, the view is offset by 20 pixels. Even if I set the frame of the modal view to 0,-20,320,480 afte...

Quartz caching CGLayer

To quote from the CGLayer doc: Quartz caches any objects that are reused, including CGLayer objects. I am having problems with memory on large pages and am trying to implement a simple mechanism where views are released and recreated based on whether they are on/off screen. Say for the sake of simplicity that I have a bunch of UI...

Presenting a modal view controller only after another one has been dismissed

I can't just do [myViewController dismissModalViewControllerAnimated:YES]; [myViewController presentModalViewController:nextModalViewController animated:YES]; one after the other, because then the two animation blocks try to affect the same references simultaneously and things break badly. So what I need to do is make the latter call...

Using (id) in Objective C

I have a function that I want to operate on two different custom objects. My first thought was to accept the argument as an (id) and operate on the id object. I can't quite seem to figure out how to do that, however. Both classes (say apples and oranges) have interface variables NSDecimalNumber *count; I want to do something simila...

Objective C Formating CGFloat

Code CGFloat a=3.45378; I want change the result to CGFloat a=3.45f; only 2 precision I know how printf works. but i dont know how to do this just keep 2 precision. ...

Whats wrong with this array? Whenever I run the action it locks up.

Why isn't this code working? The app loads fine, however whenever I press the button the application locks up (doesn't crash) and returns me to Xcode and there is a red arrow pointing to one of the lines (Indicated on the line below). I also get three warnings (not errors), one says 'NSMutableArray' may not respond to '-objectAt:' and t...

Can presentModalViewController work at startup?

I'd like to use a modal UITableView at startup to ask users for password, etc. if they are not already configured. However, the command to call the uitableview doesn't seem to work inside viewDidLoad. startup code: - (void)viewDidLoad { rootViewController = [[SettingsController alloc] initWithStyle:UITableViewStyleGrouped]; n...

Error while creating an nsarray from plist?

I am trying to create an NSArray from a .plist file, but I keep getting this error: "'NSUnknownKeyException', reason: '[<NSCFString 0x5bbca60> valueForUndefinedKey:]: this class is not key value coding-compliant for the key Value1.'" In the .plist file, I have a key called "Item 1" and a string value called "Value1." Then in the code...

What's the proper way to wrap [NSString stringWithFormat:]?

Assume I have a method with the signature: + (NSString *) myFormattedString:(NSString *)format, ...; And I want it to prepend a string of my choice (e.g. @"Foo: "). I guess the best way is to use [myString initWithFormat:arguments:], but how would you implement this method? I tried doing the following, but I get the warning as spe...

Java equivalent of Cocoa delegates / Objective-C informal protocols?

What is the Java equivalent of Cocoa delegates? (I understand that I can have an interface passed to a class, and have that class call the appropriate methods, but I'm wondering if there is any other way to achieve something closer to Cocoa/Objective-C's informal protocols) ...

How do I make a button play sounds in a certain order using an array?

I'm coding in Objective-C for the iPhone and I am trying create an array that plays a series of sounds. For example the first time I press the button I want it play sound "0.wav", but the second time I want it to play "1.wav", then "2.wav", "3.wav", etc. Then when I've played a total of 14 sounds (up to "13.wav") I want the loop to star...

How to access fetched property in Objective-C 2.0 using Core data.

I'm new to IPhone development and I'm currently trying my hand at Core Data. I have a couple entities that I've defined in my model. In one entity I have a fetched property. When I generate the Objective-C source files from my model, my entity that I defined with the fetched property does not have a property defined for the fetched prope...

How do I bind programatically in the view subclass of my NSCollectionView?

I've successfully created an NSCollectionView and added a label to the view prototype in IB, bound to a property of my represented object. I now want to programatically create an NSButton and NSTextField with the NSTextField bound to a property of my represented object. When the button is clicked I want to show and hide the NSTextField...