objective-c

Return array value as NSString

How can you return an array value (witch is a number) as a string? Current code: return [numbers objectAtIndex:row]; Have also tried: return @"%@", [numbers objectAtIndex:row]; With no luck.. Thanks :) PS: Yes, I am stupid. (: ...

Memory Management for shared array elements

I am a little confused about releasing memory for array elements that are shared by multiple arrays. Here's the scenario: Manager class has an instance variable NSMutableArray* mgrArray Helper class has an instance variable NSMutableArray* helperArray. Manager's init method: NSMutableArray* mgrArray = [[[NSMutableArray alloc] init]...

How to get UIDatePicker value in the UILable on button click.?

Hello.!! Anyone please help me to get the value of UIDatePicker to UILable on button click for IpHone Application. Thanks. ...

create multiple variables based on an int count

I tried googling this but I am not really sure what I'm searching for... In objective-c how would I create the same number of NSDictionary objects as is array.count? I would want to autorelease the dictionary objects too. EDIT: this is basically what I came up with but I'm not sure about how to make this work with objective-c syntax......

Simplifying switch statement (Objective-C)

Y'hello.. Yep, it's me again, sorry. I am trying to .. um, see the code, you'll understand. If not, I'll explain later. // When row is selected - (void)pickerView:(UIPickerView *)pickerTimer didSelectRow:(NSInteger)row inComponent:(NSInteger)component { switch (row) { case 0: NSLog(@"It obviously worked.0"); ...

UISearchBar solid color

I would like to have a UISearchBar with a solid color rather than a gradient. I have this: UISearchBar *mySearchBar = [[UISearchBar alloc] initWithFrame:self.tableView.bounds]; [mySearchBar sizeToFit]; mySearchBar.showsCancelButton = NO; mySearchBar.tintColor = [UIColor colorWithRed:0.976 green:0.489 blue:0.0824 alpha:1.0]; And it gi...

How to delay while retaining a responsive GUI on Cocoa Touch?

Basically, I have an array of buttons I want to iterate and highlight (among other things) one after another, with a delay in-between. Seems like an easy task, but I can't seem to manage to get it to work cleanly while still being responsive. I started out with this: for MyButton *button in buttons { [button highlight]; [button...

Find words between 2 words?

Using Objective-C on my iPhone, is there a built-in method for NSString that finds a string appearing BETWEEN 2 other stings? Search "my dog is my cat's best friend"... and return everything between "dog" and "best". Or will I have to write my own? Any good ideas on where to start? Thanks. ...

Waiting for a specified duration in Cocoa

Is there a more straightforward way to wait for a specific amount of time in Cocoa than what I have come up with below? - (void) buttonPressed { [self makeSomeChanges]; // give the user some visual feedback and wait a bit so he can see it [self displayThoseChangesToTheUser]; [self performSelector:@selector(buttonPressed...

Is it possible to set the contents of a CALayer from a CGLayer in iPhone SDK?

For a custom UIView I've implemented, I want to display some graphics in multiple CALayers that are added as subviews of my UIViews layer. I cannot use my UIView as the delegate for the sublayers. A UIView may only be the delegate for one layer and that is the layer the UIView already has from the get go. Since I also didn't want to sub...

Core-Data: Predicate for To-Many Relationships

I have a CoreData model with 4 entities. Model screenshot -> http://img96.imageshack.us/img96/7857/screenshot20100209at182.png State -StateName Location: -locationName (attribute) -locationDescription -locationActivities (relatinship) -state (relationship) LocationActivities: -location (relationship) ...

select part of image (clipping)

This is probably not as hard as I think it is, but how can I select part of an image? Consider the following example: The grey area is an image in the PNG or JPG Format, now I want to select the red 80x80 px area from it. The red area should be displayed, the rest not. I have tried numerous approaches: Make ckipsToBounds of UIImageV...

Does anyone have any experience using libraries to generate HTML from Objective C on the iPhone?

I need to generate some html from within an iPhone application. Do you have any recommendations on templating libraries to use? A simple Google search is turning up surprisingly empty. ...

NSObjectController confusion binding to a class property. Help!

Hi, I'm teaching myself cocoa and enjoying the experience most of the time. I have been struggling all day with a simple problem that google has let me down on. I have read the Cocoa Bindings Program Topics and think I grok it but still can't solve my issue. I have a very simple class called MTSong that has various properties. I have u...

Hiding map annotations without deleting them.

Using a MKMapView I have a pile of annoatations loaded onto it and I want to be able to filter the annotations displayed with a segmented control. I'm using custom annotations with a type variable so I can tell them apart from one another but I haven't been able to find a way to hide and display a subset of annotation views at will. ...

iPhone context: How do i extract palette information from an image?

Hi everybody: i want to take a picture and retrieve the main color analyzing its palette (i think this should be the easiest way), but i don't know really where to start. ...

How to add commas to number every 3 digits in Objective C?

If I have a number int aNum = 2000000 how do I format this so that I can display it as the NSString 2,000,000? ...

iPhone Splash: "Default.png" displays on simulator but not the iPhone

Hi there, I'm trying to give my iPhone a splash screen. I've placed Default.png in my resources group. When I run the simulator it is displayed as expected, however when I install my application to the iPhone, no splash screen is displayed. Does anyone know what the cause/solution to this problem is? Thanks! ...

Concatenating NSStrings in Objective C

How do I concatenate to NSStrings together in Objective C? ...

Objective-C ASCII to plain text

I am trying to get the ASCII numbers I load from a file to convert into plain text. I've looked at NSASCIIStringEncoding, but when I run it it just returns what I inputted. Here's the code I'm using: NSData *asciiData = [[myWords objectAtIndex:d] dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]; NSString *test = [[NSS...