29 Jul 2009, 18:09
Biopic_100x100_pragsmall

Bill Dudney (917 posts)

Hi All,

Several questions have come up about what has changed in 3.0 and how that effects these screen casts. I’ve compiled a list below of what you will need to change in the example code to be 3.0 compliant.

Several compiler warnings about using ‘deprecated’ API will be generated if you try to compile the code for 3.0. Here is a list of the categories of problems.

UITableViewCell’s text property was replaced with a text field called textLabel so all the places where the code looks like this;

cell.text = @"new text"

will have to be replaced with code like this

cell.textLabel.text = @"new text"

And any place in the code where we get the text from the cell like this;

[cell text]

has to be replaced with code like this;

[[cell textLabel] text]

Also any place where we set the text attributes such as;

cell.textColor = [UIColor yellowColor];

must be replaced with text like this;

cell.textLabel.textColor = [UIColor yellowColor];

Next the hidesAccessoryWhenEditing property was deprecated in favor of setting the accessory view type to UITableViewCellAccessoryNone when editing if you want the accessory view hidden when editing is enabled.

Finally the way table view cells are initialized was changed. The initWithFrame:reuseIdentifier: method was replaced by the initWithStyle:reuseIdentifier: for all the example code you can use the UITableViewCellStyleDefault style.

Hope this helps with your transition to 3.0!

24 Oct 2009, 18:22
Generic-user-small

John Weeks (2 posts)

Hi Bill,

Are there further changes in 3.1? I am trying the sample code (Recipes, Episode 1) and it is isn’t working. If I try to Build and Run the project file that I download from the site, I get the error:

There is no SDK with the name or path ‘iphoneos2.0’

If I instead go in and cut and paste the code in XCode, I get this error.

Cannot find protocol declaration of “UITableViewDelegate”

Thanks for the help.

John Weeks

24 Oct 2009, 22:32
Biopic_100x100_pragsmall

Bill Dudney (917 posts)

You must not have the 2.0 SDK installed. You can change the base sdk to 3.0 and it will work.

The bottom of the general tab of the projects info page (right click on project, choose get info) has a pulldown that will let you choose the 3.0 SDK.

Good luck!

25 Oct 2009, 11:24
Generic-user-small

John Weeks (2 posts)

Thanks, Bill, for the quick and helpful response. I got it working perfectly.

01 Dec 2009, 08:52
Generic-user-small

Paul Baptist (2 posts)

Hi Bill!

I’ve been working with the source code for episodes 3-5, and the readonly recipes property we created in the app delegate is producing the following error: “synthesized property ‘recipes’ must either be named the same as a compatible ivar or must explicitly name an ivar”. Any idea what’s causing the break? I’ve got version 3.2.1 of the SDK, but I’m telling it to compile as version 3.0 for the time being and still getting the error. It’ll run if I disable the synthesize statement in RecipesAppDelegate.m (which is the line causing the problem), however the input box to add recipes has a black background as a result.

01 Dec 2009, 13:09
Biopic_100x100_pragsmall

Bill Dudney (917 posts)

Hi Paul,

The property and the ivar must be named exactly the same or you have to tell the compiler about the linkage. For example

@class Foo :NSObject {
  NSArray *_recipes;
}

@property(nonatomic, retain)NSArray *recipes;

@end
@implementation Foo

@synthesize recipes = _recipes;

@end

The ‘=’ sign in the @synthesize statement lets the compiler know which ivar you want it to use.

Good luck!

01 Dec 2009, 22:16
Generic-user-small

Paul Baptist (2 posts)

Ok, I tried putting the class definition right above the @property defining recipes, and it’s giving me two “Expected identifier or ‘(‘ before ‘class’” warnings for the line with the class declaration, and still claiming an incompatible type for the ivar on the @synthesize statement. Any other ideas for tweaking it to make this work?

01 Dec 2009, 23:05
Biopic_100x100_pragsmall

Bill Dudney (917 posts)

Sorry Paul I don’t understand your question.

04 Dec 2009, 19:13
Generic-user-small

Anssi Korpilaakso (1 post)

Hi Bill. I have a same problem like a Paul. RecipesAppDelegate.m file and point @synthesize recipes; says error: “synthesized property ‘recipes’ must either be named the same as a compatible ivar or must explicitly name an ivar” Any ideas?

05 Dec 2009, 04:25
Biopic_100x100_pragsmall

Bill Dudney (917 posts)

Hi Anssi,

Your problem has nothing to do whatever with 3.0.

In you .h file

@interface Foo : NSObject { }

@property(nonatomic, retain) Baz *zippy;

@end

In the implementation file;

@implementation Foo @synthesize zippy; «««——- this name has to match the @property decl in the header @end

good luck.

10 Dec 2009, 21:18
Myavatar_pragsmall

Christopher Miller (1 post)

Hey Paul and Anssi,

Just comment out

@synthesize recipes;

The property is already implemented as

` - (NSArray *)recipes {

    return [data allKeys];

}

`

05 Apr 2010, 18:43
Generic-user-small

Thomas Curley (1 post)

Hi Bill,

I have recently purchased the screencasts and now I am going through video number 4. In the video you implement a method called commitEditingStyle: and inside this method there is this line of code.

‘[self removeIngredients:[[tv cellForRowAtIndexPath:indexPath] text]];’

When I compile the source I get a warning saying ‘text’ is deprecated, I think it is because I am using version 3.1.3. I have tried different solutions but no luck.

Can you please help?

Cheers mate.

01 May 2010, 03:14
Me_pragsmall

David Knell (1 post)

Thomas,

In 3.0 the ‘text’ property is deprecated. You must now use [[cell textLabel] text]. If you haven’t already found a solution, try this:

[self removeIngredients:[[[tv cellForRowAtIndexPath:indexPath] textLabel] text]];

Dave

27 Jul 2010, 23:16
Generic-user-small

Reinaldo Garcia (3 posts)

Bill, the synthetize error seems to have something to do with this issue: http://stackoverflow.com/questions/1155267/iphone-simulator-build-errors-when-using-synthesized-instance-variables

How can I get the sample code running again?

Thanks

07 Aug 2010, 19:38
Generic-user-small

Emre Besirik (1 post)

Hi,

I’m having some trouble;

RecipesAppDelegate.m:34: error: request for member 'ingredients' in something not a structure or union

for;

IngredientsController.ingredients = [self ingredientsForRecipe:recipeName];

scratch that, I figured out my self :) thanx ;)

19 Aug 2010, 20:36
Generic-user-small

Antony Boggis (1 post)

Bill, looking at purchasing the series, but am curious to know if you have any plans to update it to iOS4?

11 Dec 2010, 22:19
Generic-user-small

Darren Gow-Brown (1 post)

Hi Bill,

I think your concept, Writing Your first iphone Application, with 5 Episodes to which I have purchased, only to find they are fantastic.

I made the changes to my recipes code and now have the green Build Succeeded, well done on your part.

Let me emphasise the power of learning I have 3 books sitting here, but it was your tutorials that made the difference to really understand and that its not black magic its realistic.

I have a very long way to go and I believe this site will help me achieve my goal to complete my app this Xmas 2010

If you are ever interested in making custom templates Please e-mail me

I ask that you consider to update all iphone development tutorials and if you do I would be interested to invest further

Kind regards

Darren Down under

13 Dec 2010, 11:48
Mark-web-picture-480-square-close_pragsmall

Mark Tomlinson (1 post)

Just bought these and wanted to say thanks for keeping the Addendum up to date, I realised the videos were from 2008, but the concepts are still sound and I enjoy your presentation style. Thanks again for the updates.

21 Feb 2011, 18:43
Generic-user-small

Darren Harrison (1 post)

Any chance that these videos will be updated for the latest version of SDK? I get many warnings and have not a clue how to fix them.

Example:

  • (void)recipeClicked:(NSString *)recipeName { [navController pushViewController:ingredientsController animated:YES]; } Tells me “ incompatible Objective-C types ‘struct IngredientsViewController *’, expected ‘struct UIViewController *’ when passing argument 1 of ‘pushViewController:animated:’ from distinct Objective-C type “

I tell you working with the interfaces iPhone is very complicated…how does one know when to use what and where? Is it something that has to be memorized over time, because I have read many books and seen many vids but it still hardly makes since.

  You must be logged in to comment