objective-c

How to Start UITableView on the Last Cell?

In Apple's Messages app, when you click a correspondent's name and switch to the table view of the conversation (with balloons for each message), the table appears scrolled all the way to the end. No animation or anything, it's just there. Similarly, in Tweetie 2, when you load the tweets view, it appears right where you last looked at ...

How to process Reference Movie in iPhone app?

I followed Apple tutorial, Apple - QuickTime - Tutorials - Reference Movies, to create reference movie in my web site. In summary, "A reference movie contains pointers to alternate data rate movies--that is, multiple versions of the movie designed for downloading at various data rates". In my app, I use MPMoviePlayer and provide it wit...

What does this syntax mean in Objective-C?

Consider the following: - (id)initWithTitle:(NSString *)newTitle boxOfficeGross:(NSNumber *)newBoxOfficeGross summary:(NSString *)newSummary; What does this mean? I've guessed that it returns id, and takes three params, but what does each part of the syntax mean? I come from a Ruby/JS background and am finding this ...

Possible bug in Interface Builder?

Hi, I've a window with a horizontal split view. On the bottom pane of the split view, I have a nssegmentedcontrol, aligned to the center. On the bottom of the nssegmentedcontrol I have 5 tabs that are controlled by the segmented control - click in one of the cells and the corresponding tab opens. My problem is, if I completely minimize...

Cocoa Touch UITextField first character uppercase

Hi, I have a UITextField. How can I make sure that the first character is uppercase? I tried this. - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { NSUInteger newLength = [textField.text length] + [string length] - range.length; if (newLength == 1) { str...

How can I display documentation in Xcode via CodeSense?

I am Java developer and would like to know how I can get the equivalent of a JavaDoc in Xcode when CodeSense is doing its auto-complete? If I hit the ESC button I can get a list of methods etc. but it does not show me the descriptions of what the methods do. ...

Why doesn't Objective-C support private methods?

I've seen a number of strategies for declaring semi-private methods in Objective-C, but there does not seem to be a way to make a truly private method. I accept that. But, why is this so? Every explanation I've essentially says, "you can't do it, but here's a close approximation." There are a number of keywords applied to ivars (memb...

Set graphics context to display UIImage (Obj-C)

Hi, I'm trying to render a UIImage in Objective-C (working on a simple iPhone app (breakout-type thing) to get used to the environment). However, I'm getting an "Error: CGContextDrawImage: invalid context" error when I try and draw it. My question is: how do I set the context that the DrawAtPoint method of UIImage uses? Here the rele...

Updating/Removing UILables from View

hi, i'm creating some UILabels in my UIView, filling them with data, adding them to view and releasing them UILabel *speed = [self scrollLabel:@"some Text" x:455.0f y:75.0f]; [scrollView addSubview:speed]; [speed release]; the method: - (UILabel *)scrollLabel:(NSString *)text x:(float)x_ y:(float)y_ { UILabel *label = [[UILabel al...

Is there way to keep a text view and a slider in sync to a CGRect's float value with bindings?

I've been trying to get a text view and a slider to be updated to the correct value when either one has been modified. Using bindings, I've successfully linked each control to a CALayer's "x" value position (layer.position.x). The layer does move when any of the controls are changed. However, when modifying one of the controls, I canno...

detecting email account from within an iPhone application

Is there a way to know the email addresses to which the user has linked his iPhone to from within an iPhone application? ...

"Extension Methods" in Objective-C

How do I write my own "extension method" in objective-c? http://code.google.com/p/json-framework/ This library does it and it works like this. NSString *myString = ...; id myResult = [myString JSONValue]; where the myResult returns an NSDictionary or NSArray. What are these called? How do I write my own? ...

NSURLCache crashes with autoreleased objects, but leaks otherwise...

UPDATE: After submitting a radar to Apple it appears that this is a known issue (Radar #7640470). CSURLCache is designed to cache resources for offline browsing, as NSURLCache only stores data in-memory. If cachedResponse is autoreleased before returning the application crashes, if not, the objects are simply leaked. Any light that co...

refreshing singleton object data in object c

here is code + (SalesCollection*)sharedCollection { @synchronized(self) { if (sharedInstance == nil) { [[self alloc] init]; // assignment not done here } } return sharedInstance; } + (id)allocWithZone:(NSZone *)zone { @synchronized(self) { if (sharedInstance == nil) { sharedInstance = [super allocWithZone:z...

Cleaner way to make the controller's setter explicitly propagate the change to the CALayer.

My previous question asked for a way to keep a text view and slider in sync with bindings when modifying a CGRect's "x" value. Following Peter Hosey's advice on using the controller's setter to propogate those changes to the CALayer, I came up with the following: @interface WindowController : NSObject { CALayer *layer; float frameO...

Can I speed up my use of Core Graphics to draw moving triangles every 1/10th of a second

I have recently added some Core Graphics elements to my app and it has slowed dramatically, rendering it just about useless. I am not sure if I am just not using Core Graphics efficiently (how do I make it faster?) or if this problem is inherent in the use of Core Graphics. My code is below, after this description: There are speech bubb...

Unable to build project with CoreData classes

I am trying to migrate my sandpit code into my main project but for some reason I am getting the following strange error when trying to compile syntax error before 'NSManagedObjectModel' At first I thought this was because coredata wasnt in the prefix.pch file but I have added it in there too. This is the top of AppDelegate where ...

Cocoa Development - How to get specific information about media files (Duration, Bitrate, FPS, etc.)

Hi, I need to get the same kind of info that you can get on "get info" when using Finder, more specifically I need the same info that is present on "more info" section, like Duration, Bitrate, Dimension, Codecs, Audio channels, etc. To get the basic info like size, type, I have: // Getting the file's attributes NSError *error; ...

Difference between @interface declaration and @property declaration

I'm new to C, new to objective C. For an iPhone subclass, Im declaring variables I want to be visible to all methods in a class into the @interface class definition eg @interface myclass : UIImageView { int aVar; } and then I declare it again as @property int aVar; And then later I @synthesize aVar; Can you help me understa...

UITabBar + UINavigationBar conflict title

Hi, I have a UITabBar and a UINavigationBar created in IB, when I launch my application everytime I navigate the UINavigation title change because I'm using self.title = @"NAME"; my problem is that the UITabBarItem will change with the same name at the same time. I want to put a static name only for the UITabBarItem, how to do it i...