objective-c

Does dealloc get called after viewDidUnload?

A quick question, after viewDidUnload does the dealloc also get called? I am asking with regards to pickerData, it was my understanding that the variable would be released when the dealloc gets called. My reason for asking is that I have noticed in one book that the author sets pickerData to nil in the viewDidUnload. Is this harmless ove...

How is the @encode compiler directive implemented in Objective-C?

Can anyone explain how @encode works to extract the datatype elements present in a given object, struct, or datatype into a type definition to be used as a class descriptor for instantiation? Or maybe a pointer to some resources for learning about the implementation of new preprocessor directives? ...

Objective-C Preferences Window makeKeyAndOrderFront or showWindow?

Hello everybody, I'm working on a new Mac App and want to open my Preferences Window, i've got 2 Nib (xib) Files, one for the main window, and one for the Preferences Window, then i've got a openPreferences Action, which shows the Preferences Window, sth. like this: - (IBAction)openPreferences:(id)sender { PrefCont *cont = [[PrefCo...

Simplified asserts in OCUnit

I just started jusing OCUnit and find the asserts a bit cumbersome. In JUnit I can write a test to compare numbers like below. This test will obviously fail, but this shows the nice, simple assert I can write for two numbers and the feedback I get: "expected <2> but was <3>" with very little code. What I tried so far i XCode is: Wh...

initWithBarButtonItem change from UIBarButtonSystemItemPause to UIBarButtonSystemItemPlay?

My application has a UIBarButtonItem with a UIBarButtonItemPause icon in the upper right corner of the screen on a UINavigationBar. I'm looking to have it so that when I press the button it changes the icon to a play button, and back to a pause button when it is unpaused (similar to the way in which iTunes, Quicktime, or iPhone's integra...

ObjC/Core Data. How can I change the key value of an entity from another NSArrayController?

Hi, I am completely noob in objective-c and I am trying the whole day to find a solution to this problem: I have two entities (Storage and Expenses). In Storage I have an attribute "number". In Expenses I have an attribute "number" and another called "cost" Both entities are linked to tables via cocoa-bindings I have created subclasses...

how to move title over in iphone navigation bar

I wish I could show you all a picture, but I have two buttons on the top right of my nav bar and a refresh button on the left. The title is in the middle, but the first two letters are getting overwritten by one of the buttons on the right. How do I 'push' my title (or titleview - either one) so that the title moves over a bit? I want t...

How to add a property to NSObject in Objective-C?

I'm using the following code to add a displayValue method to NSObject: @interface NSObject (MyNSObjectAdditions) - (NSString*)displayValue; @end @implementation NSObject (MyNSObjectAdditions) - (NSString*)displayValue { return self.description; } @end This works great, but really I'd rather have displayValue be a read-only prope...

Using the UIImagePickerController image editor seperately

When you are using an UIImagePickerController, you have a property called allowsImageEditing, which makes it possible to zoom in/crop/etc a picture, after you picked a picture (from camera or library). I would like to use this editor just with an UIImage as a source, the images are loaded from the internet and I want the user to be able...

Is there a convention for naming initializer method in objective-c?

In an objective-c class that can be initialized through different init... methods, it is common sense to collect initialization code that is common to all initializers into one common method that is called from the other init* methods (or also sometimes from awakeFromNib). Is there a convention for how this method should be named? initi...

Multiple Unrelated Entities in one Core Data Model

Hi, I want to have the equivalent of two completely unrelated tables in my database, and for this I have defined two different entities in my Core Data model. Further to this, I have a different ViewController making use of each of these entities and therefore I'm initializing two different fetchedResultsController (one in each ViewC...

iPhone: Reading Text From File and UISegmentedControl

First off, I'm a complete beginner. That said, I thought an ambitious longer-term project/learning experience would be to create an app that displayed daily quotes, like those cheesy day-by-day calendars our grandmothers have in their bathrooms. I want it to have two per day, each one represented by a tab in a UISegmentedControl. That...

Does dealloc get called on iPhone?

I have noticed whist learning how Cocoa-Touch works over the last few weeks that dealloc methods don't seem to be getting called when I exit the app in the iPhone simulator. Now to be fair I am not doing anything too scientific just putting in NSlog statements that can print to the console. My questions is: (1) Does the simulator discon...

Should I nil delegate references made through Interface Builder?

If I assign a delegate property from classB to classA from Interface Builder, should I assign an IBOutlet to classB, then in classA dealloc, set the delegate to nil via the outlet? (Assuming classA is the file's owner of the XIB...) ...

When I refer to programming in Objective-C should I include the 2.0?

This may be subjective but if I'm writing some code in Objective-C 2.0 and write about it on for example Twitter or a blog. Should I refer to it as Objective-C 2.0 or can I just call it Objective-C? ...

Why are certain lines in my Cocoa application taking forever to run?

I'm having a very strange problem. I'm running a loop in a detached thread, and some lines of code in my loop (different lines in each iteration of the loop) are taking a long long time (~45 seconds) to execute, even if they are simple commands like initializing an NSXMLDocument with data. This problem is also very inconsistent, and it d...

Use of pass by reference in Objective-C

Looking at the JSON-Framework source, it makes heavy use of pass by reference in many of the parser method signatures. i.e. @interface SBJsonParser () - (BOOL)scanValue:(NSObject **)o; - (BOOL)scanRestOfArray:(NSMutableArray **)o; - (BOOL)scanRestOfDictionary:(NSMutableDictionary **)o; @end This ends up being used something like...

Setting text for NSTextView with an NSString variable, considering reference counting

I have the following code in a function in my .m file: desc = [my executeFunction]; // desc is returned by executeFunction data = [desc objectAtIndex:0]; // data is declared in the .h file data2 = [desc objectAtIndex:1]; [myTextField setString:data]; // myTextField is connected to an NSTextView in IB [myTextField setString:da...

All the app in iphone appear in a "grid icon" layout, how can I achieve that layout?

when u first open up iphone, all the app are layout in a "grid icon" type. And if u have too many app, the user swipe to the right, and the new view come out, with again all the app appear in a "grid icon" layout. Can u guys point me to where I can achieve such a design. Code would be very appreciated !!! I did try something and here is ...

iPhone view hierarchy question: How do I draw views over the tab bar?

I am having some trouble with view hierarchies and drawing on the iPhone. To be more specific, I have a tab bar application with a certain tab that contains a table view where I would like the selection of a specific cell to have a UIPickerView slide up. The sliding isn't really a problem (or at least I'm assuming it won't be once I fig...