johnreilly

www.flickr.com
john.reilly's items Go to john.reilly's photostream

Posts tagged "xcode"

new to obj-c

I’m working my way through the Pragmatic iPhone screencasts, and my complete newbosity to Objective-C is thoroughly kicking my ass.

Basically, there’s a main application delegate that has a property on it for data shared amongst other controllers. The controllers “should” be able to access it… as far as I can tell I’ve set up all my connections and @synthesize’ed it correctly, and the property appears in Xcode’s autocomplete. But, the compiler? Not so happy.

Objective-C error

Whenever I try to access the delegate’s property (in this case, the property is called “recipes”) in a controller, Xcode spits out an error:

Request for member ‘recipes’ in something not a structure or union

To me, this seems like an old school C pointer de-referencing problem, which I thought Obj-C’s @property and @synthesize bits would have done away with.

I’m at a loss. Any suggestions?

Update

Turns out I wasn’t including the header files for the app delegate class. So, the particular implementation I was working in had no idea what properties/methods were available on the app delegate.

If you look at the screenshot above, I simply added the following line just below the first #import statement:

#import "RecipesAppDelegate.h"

In hindsight, this was a rather silly mistake on my part (but hopefully forgivable since this is my first day with Obj-C…). But what strikes me as weird is that Bill (the screencast’s author) never added the header file during the screencast.

Was it somehow added automagically in his project when connecting up the delegate outlet in Interface Builder? Who knows. At least I’ve got it running now… On to the next section. :)

Comments (View)