objective-c

Objective c time delay

Here is my code so far: - (IBAction) startApproximiteLevel:(id)sender { [getBackgroundLevel startAnimation:self]; float sample1; float sample2; float sample3; float sample4; float sample5; float finalSample; float charlieSoundVolume = [charlieSoundLevel floatValue]; sample1 = charlieSoundVolume; sleep(1) sample2 = charlieSoundVolume; ...

Objective-C: Setting autoreleased objects to nil

Is it safe to set an autoreleased object to nil? I know I don't need to release an autoreleased object but if I want the object to be released immediately to minimize memory use, can I set the object to nil?. I may have read this somewhere a while back, but I can't remember where and I want to make sure that it is safe to do that. ...

When using the UIImagePickerController in iOS4 to pick from the photo library can you start w/newest first?

Is there a way to show the UIImagePickerController photo library interface such that when it comes up it starts at the bottom of the library which is where the newest images are in iOS4? Apparently this is how it worked in 3.x. Thanks ...

Add an icon (mac & pc) to a file with Cocoa

I want to add an icon (icns & ico) to a file within my iPhone app and I'm not quite sure where to start looking! So when this file is viewed in Finder or Windows Explorer it will have a custom icon. Can anyone point me in the right direction? ...

View of custom class

Hello, I have the following class: @interface Gamer { ... } +(id) CreatePlayer; @end @implementation Gamer +(id) CreatePlayer { return [[[self alloc] init]autorelease]; } @end I need to use the Gamer in an another class as instance variable. For example like this: @interface Layer{ Gamer * mCenterGamer; } @end @implementation ...

Confused about NSCFTimer... what is it?

Could someone tell me what exactly NSCFTimer is? I get it when I ask NSTimer for a timer. My problem is that I'm trying to check if an object (supposedly an NSTimer, note the word "supposedly" which is why I'm checking) is an object of class NSTimer, it doesn't seem to work. Does this "NSCFTimer" in any way... hinder the process? ...

Should I set up a protocol for Objective C array objects to avoid a compiler warning?

I have a class, let's call it ABC, with an NSArray *objects property, and the objects in the NSArray can be one of two different classes, X and Y. Both X and Y have a path property, but the compiler doesn't know this. Therefore, even though ABC will always find the path property on my array objects, I get compiler warnings on my code -...

Objects inside NSAutoreleasePool in objective-c

Is there a way to know the objects that are marked for releasing inside an NSAutoreleasePool. ...

NSNumber weirdo .... ?

Hi, for a day now I stare at the following routine and can't get my grips around it. I have a class such as: MyClass.h ... @interface MyClass : NSObject { NSNumber *myNumber1; NSNumber *myNumber2; } @property (nonatomic, retain) NSNumber *myNumber1; @property (nonatomic, retain) NSNumber *myNumber2; @end and the m-file #i...

How to keep iPhone screen from reducing backlight..?

My app shows a picture and then an mp3 plays over it, describing the picture. The trouble is that the backlight on the screen reduces after 40 seconds or so, if the phone is not interacted with. How do I prevent the fade?...so that my picture doesn't go dark when they are looking at it. ...

Objective-C: How to implement TextView orphan control

I'm working on an iPad app that does a simple display of text similar to iBooks. I would like to display ONLY full paragraphs on each screen (ie, no orphan/widows on a page). Similar to iBooks, I want to allow the user to change the font and font size and continue to keep all lines in paragraphs together. The user will be able to page...

iPad app navigation bar with multiple buttons on the same side

how can I have a back button and another button both on the left side of the nav bar? since this is an ipad app there's space for multiple buttons. but I can only get it to show one button per side on the navigationitem... ...

Difficult exluding objects based on key while enumerating an NSMutableDictionary

I'm stumped. I have an NSMutableDictionary w/ nested dictionaries that I am enumerating through to create an Array of a particular key value in a nested dictionary, but I want to exlude two "keys". I am able to do it if I exclude one key, but as soon as I try to use the "||" or operator in my If statement it stops working and just adds ...

How to put gradient style table cell in a table?

Hey, I am making a custom table cell right now but my custom cell is just white cell with some buttons and labels in background color which looks not that great. Is there a way to render the background color so that the cell has some vertical gradient effect? For example, on top of the cell it looks white and as it gets closer to center ...

objective-c memory management question

do you need to release something very simple this? NSString *a = @"Hello"; //[a release]; ? i come from a java/c# world, and am confused about when things should be released/retained... ...

Can't display UIImage in UIImageView

Hi all, i want to display an UIImage within a UIImageView but it doesn't work and i don't know why. could you please help me. i am using the following coding: -(void) showCorrectedImage { MyAppDelegate *delegate = (MyAppDelegate *)[[UIApplication sharedApplication] delegate]; CorrectedImageController *imageController = [[Corrected...

Why is my text flip over when using CGContextShowAtPoint?

Hi, I am writing a simple practice. However, my text is flip upside down when I trying to use CGContext to put some string on the UIView, I am wondering why and how to change it into correct format. Here is my code in the drawRect char *string = "TEST"; CGContextRef context = UIGraphicsGetCurrentContext(); CGContextBeginPath(cont...

Best method to get text to blink in iPhone OS?

I want my text box to blink (like the old LCD clocks) and right now I'm calling a myriad of NSTimers and selectors that wait, change the alpha, wait, then change it back. Even with this it looks really bad, and I'm thinking I have to put an NSTimer to gradually change the alpha, but from what I hear they are not meant for things of that ...

How to keep image from autorotating?

I've got an UIImageView as a background image for my application, which, like a helicopter in distress, autorotates. The problem is when the orientation autorotates my image gets shifted all over the place and I don't like it. Since it's a simple texture I figure the user would prefer to have it stay in its place, and not autorotate. Wha...

Multi-parameter mapping with Three20 and TTURLMap

I'm following this tutorial and declare the following mappings in my app delegate: [map from:@"x://profile/(initWithId:)/(name:)" toViewController:[ProfileViewController class]]; [map from:@"*" toViewController:[TTWebController class]]; In ProfileViewController.m I implement the - (id)initWithId:(int)anIdentifier name:(NSString *)name...