objective-c

How to add button to UINavigationController.

I have the following code with adds a navigation controller to a modal view. The nav bar and view all appear ok, but the right button does not. What am I doing wrong? UpgradesViewController* upgradesViewController = [[UpgradesViewController alloc] initWithNibName:@"UpgradesView" bundle:nil]; upgradesViewController.title = @"Upg...

Should I learn a operating system specific language or something like Java?

I am torn. I want to start making applications for OS X. There is a specifically under-served market that I would like to tap but I don't know if I should develop it only for the mac with Cocoa and Objective C or if I should develop it with Java and JavaFX. I guess my question is, is Java robust enough to handle the same things as Objec...

Is there any way to retrieve a float from a varargs function's parameters?

If the function was defined with a prototype which explicitly stated the types of the parameters, eg. void somefunc(int arg1, float arg2); but is implemented as void somefunc(int arg1, ...) { ... } is it possible to use va_arg to retrieve a float? It's normally prevented from doing this because varargs functions have implicit typ...

UITableView cellForRowAtIndexPath occasionally not called?

I'm developing a graphing application that on the main navigation/tab view displays a UIView that renders a graph using openGL. Beneath that view is a UITableView that displays the list of elements on the graph, and an add button. Occasionally, when the user clicks on another tab, and then returns to the graph view tab, the table view d...

Can a standard accessory view be in a different position within a uitableviewcell?

I want my accessory to be in a slightly different place than normal. Is it possible? This code has no effect: cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; cell.accessoryView.frame = CGRectMake(5.0, 5.0, 5.0, 5.0); ...

Instantiate UITextField delegate programatically?

I have a UITextField that has been added to my view in Interface Builder. My question is: is there a way I can programatically set its delegate from within Xcode? I know that I can connect up the delegate in IB by dragging a connection from UITextField>Delegate to my viewController which implements textFieldShouldReturn: Just curious as...

Optionally set navigationbar background image

I have the need to draw a background image or set a tint color on a navigation bar, but I also need the option to have the navigation bar appear as it normally would. I'm currently using a category to support If my app does not specify a background image, what can I do instead to ensure the drawRect method does it normally would do? I.E...

How to migrate new data model in a CoreData project ?

Hi I have a simple problem, I have an app based on CoreData and I need to change the structure a little. How can I migrate the old structure into the new one. Just adding one attribute will chrash the whole app. Thanks ...

How do I reset the state of a view inside a tabbar?

Hello CocoaTouch-Experts! This is a fairly straightforward question though my Googling session gave me nothing. How do I reset the state of a view hierarchy located in a tabbar programmatically? The behavior I want to replicate is when the user tapps on a tab twice. This causes the view located under that tab to return to it's initia...

Objective C memory leaking

Hi everyone, I'm creating one Cocoa application for myself and I found a problem. I have two NSTextFields and they're connected to each other as nextKeyViews. When I run this app with memory leaks detection tool and tab through those 2 textboxes for a while, enter some text etc., I start to leak memory. It shows me that the AppKit librar...

How do you call a method for an Objective-C object's superclass from elsewhere?

If you're implementing a subclass, you can, within your implementation, explicitly call the superclass's method, even if you've overridden that method, i.e.: [self overriddenMethod]; //calls the subclass's method [super overriddenMethod]; //calls the superclass's method What if you want to call the superclass's method from somewhere o...

Pointers to good reference on writing AppleScriptable Cocoa project?

I've got an Objective-C program that I need to make AppleScriptable. I've looked through the Apple references and they're all at exactly the wrong level, either for the applescripter, or too high level, or too low level. Can anyone point me at a good resource for getting started on this? or perhaps a sample project I can poke at? than...

IPhone: Controllers, Delagates, DataSources, etc all in one class?

Hi All, I am learning iPhone programming. I am starting with a simple example of displaying recently used documents in a UITableView. What I am confused about is why do I need to have several classes and why cant I just use one? Example, My class is called RecentFileList. I need to implement controller, delegate and datasource as wel...

Is there a difference between NSString compare: and isEqual(ToString): ?

Occasionally I find code which tests if two NSStrings are the same like this: if ([str1 compare:str2] == NSOrderedSame) { // Do something } Now, I believe this is less readable than using isEqualToString: and it also has some nasty side effects, like if str1 == nil the if(..) evaluates to true, or when str2 == nil havoc might brea...

Converting "fr_FR" into "French (France)" in both directions. (Objective-C iPhone)

I can easily change a short region-code (en_US) into a longer string... but it there an easy way to also move in the other direction? [displayInEnglish displayNameForKey:NSLocaleIdentifier value:regionCountryCode]; "en_US" becomes "English (United States)". "English (United States)" becomes "en_US". I currently store the short regio...

How many simultaneous (concurrent) network connections does iphone support?

I can't seem to find this anywhere, but I'm sure there must be an answer... How many simultaneous HTTP connections can an iphone app service? In other words, if I build and run a bunch of NSURLConnections asynchronously, how many can be in flight before it starts queuing them? Also, is there a method to check how many threads are avai...

dealloc properties with assign and readwrite objective-c

I have this structure: @interface MyList : NSObject { NSString* operation; NSString* link; } @property (readwrite) NSString* operation; @property (readwrite, assign) NSString* link; @end @implementation MyList @synthesize operation,link; @end I know that if I had retain instead of readwrite I should release the operation ...

Drawer detaching when window is resized

For some reason in my Cocoa application when I resize the parent window, the drawer doesn't move with it. It just stays where it is on the screen and is detached from the window. I built it using the "Window and Drawer" object and I think it used to work. Everything else about it still works fine (i.e. toggling, etc). I have compared a...

Adding a dynamic-height UITableView into a scrolling view?

Hello all – I'm getting into iPhone development and have hit my first confusing UI point. Here's the situation: My app is tab-based, and the view that I'm confused about has a static featured content image at the top, then a dynamic list below into which X headlines are loaded. My goal is to have the height of the headline table grow as...

OBJ C filling arrays in awakefromnib - scope question?

Hey all: I'm attempting to fill an array, called from awakeFromNib. My problem is that the variable isn't visible when I try to access it. Here's the relevant snippet: -(id)returnHaiku { return [self getOne:[self getOne:five]] // doesn't know what "five" is... } - (void)awakeFromNib { [super awakeFromNib]; [self fillA...