objective-c

NSThread and object retain count issue

I want to be able to call an object's method on a new thread; but, I am confused about how to manage retain counts (or even if it is an issue). In a non-threaded scenario, I would do this: MyObject *newObject = [[MyObject alloc] init]; [newObject doSomething]; [newObject release]; In this scenario, everything's fine. However, my ques...

jerky effect in the movement of objects

hi im trying to create a game in which few objects(UIImageViews) traverse the screen... these objects are generated at an interval of 1 to 0.45 seconds...when they r generating in the range of 1-0.60 seconds they traverse smoothly..but when they generate at a rate less than 0.6 seconds their movement is not smooth they start jerking..als...

Casting NSString to unsigned char *

Hi, I'm trying to use a function that has the following signature to sign a HTTP request: extern void hmac_sha1(const unsigned char *inText, int inTextLength, unsigned char* inKey, const unsigned int inKeyLength, unsigned char *outDigest); And this is the method I wrote to use it: - (NSString *)sign: (NSString *)stringToSign { NSStr...

NSString is integer?

How to check if the content of a NSString is an integer value? Is there any readily available way? There got to be some better way then doing something like this: - (BOOL)isInteger:(NSString *)toCheck { if([toCheck intValue] != 0) { return true; } else if([toCheck isEqualToString:@"0"]) { return true; } else { return ...

Adding left button to UINavigationBar (iPhone)

I've created a new navigation based iPhone app. I added this to the RootViewController. - (void)viewDidLoad { [super viewDidLoad]; UIBarButtonItem *addButton = [[UIBarButtonItem alloc] init]; self.navigationItem.leftBarButtonItem = addButton; self.navigationItem.leftBarButtonItem.enabled = YES; } No left button displays howev...

What's the best way to parse RSS/Atom feeds for an iPhone application?

So I understand that there are a few options available as far as parsing straight XML goes: NSXMLParser, TouchXML from TouchCode, etc. That's all fine, and seems to work fine for me. The real problem here is that there are dozens of small variations in RSS feeds (and Atom feeds too), so supporting all possible permutations of feeds avai...

Retrieving current local time on iPhone?

I'm looking to get the current hour and minute on a user's iPhone for display in an app that doesn't show the status bar. Is there a simple way to do this? Thanks, Ben ...

What is this double underscore in Cocoa

The single underscore in Objective-C is apparently reserved for Apple's "internal" use (and was available for use with private instance variables prior to Apple's claim). But why would they use a double-underscore in their SQLiteBooks example for the iPhone? See this snippet taken from MasterViewController.m: + (EditingViewController *)...

Objective-C networking - best practices?

Hi, I'm building an Objective-C app that has both a server and a client. The client can send updates to the server, and the server needs to be able to send updates to each connected client. I've been thinking about how best to implement this system, but am asking for your suggestions. Currently, I'm thinking that when new updates are av...

Is it possible to bind the null placeholder in Cocoa?

I have a table where certain cells will be nil until the user fills them in, but I was hoping that I could change the null place-holder (i.e. the value it displays when the particular value for that cell is nil) depending on other parts of the application the user has already filled in or configured. Sort of like an auto-complete but not...

Responding to touchesBegan in UIPickerView instead of UIView

I have a UIPickerView that gets faded out to 20% alpha when not in use. I want the user to be able to touch the picker and have it fade back in. I can get it to work if I put a touchesBegan method on the main View, but this only works when the user touches the View. I tried sub-classing UIPickerView and having a touchesBegan in there, b...

how can I call a screen with a button action (xcode) ?

I am developing a Window Based app for iPhone. I use Interface Builder to build Interface. I want to call a new screen with a Button Action. How can I call the screen with Button action ? ...

two AlertView in same Viewcontroller

i have two Alertview in same viewcontroller and i want to use the delegate method -(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger) buttonIndex this method will get called when button in alertview been pressed however both alertview will call the same method how can i different the two alertView? ...

What's the best way to communicate between view controllers?

Hi Stack Overflow Gang, Being new to objective-c, cocoa, and iPhone dev in general, I have a strong desire to get the most out of the language and the frameworks. One of the resources I'm using is Stanford's CS193P class notes that they have left on the web. It includes lecture notes, assignments and sample code, and since the course ...

Retriving the retain count for a CGImageRef object?

While you can release a reference to a CGImageRef object using "CGImageRelease", which, according to the SDK this "decrements the retain count of a bitmap image", is there a way to inspect the current retain count for a CGImageRef instance? [cgImageRef retainCount] isn't valid since CGImageRef isn't a valid receiver of the retainCount m...

Copying UITableViewCell

I'm reading a custom table cell in tableView:cellForRowAtIndexPath: from a nib file. This works great for my purposes, except it's quite slow. Now, I know the right thing to do in the long term is to create the cell entirely in code, and to use a single view, and so on. But this is a prototype, and I don't want to put that much effort i...

CALayer addSublayer increasing retain count?

I think that when I add a view as a subview like such: UIView* view = [[UIView alloc] init]; [self addSubview:view]; [view release]; that it's safe to release the view afterwards...is it the same for a CALayer object? If I create a CALayer using alloc/init, and do: [self.layer addSublayer:layer]; is it safe to do a release of the l...

NSColor with calibrated values works differently than regular color??

I'm using a method in my view to set a color, and in awakeFromNib I pass it a color using [NSColor colorWithCalibratedRed: green: blue: alpha:] The application kept crashing, with the error with "[NSCFNumber set] unrecognized selector." After inserting a breakpoint, I found it was defining my variable as an "NSCalibratedRGBColor." The a...

Convert seconds to days, minutes, and hours in Obj-c

In objective-c, how can I convert an integer (representing seconds) to days, minutes, an hours? Thanks! ...

NSDate and NSDateFormatter issues

I'm having slight difficult understanding why the following code is crashing an app of mine: NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateFormat:@"MMMM d, yyyy"]; NSDate *date = [dateFormatter dateFromString:cDate]; datePicker.date = date; NSString *dateStr = [dateFormatter stringFromDate:date];...