07 May 2009, 19:01
Generic-user-small

Simon Warbey (2 posts)

I’ve just worked through Chapter 3 (View Controllers) of the current ebook pdf. My project compiles correctly and runs in the Simulator (2.2.1) but it’s not functioning as I expect.

The initial view has all the defaults, but when I click Edit and the Edit View comes in, all the fields are blank. Clicking Done I go back to the main view and nothing has updated. If I select Edit again, the Edit View again comes in, this time populated with all the values as expected.

A similar thing happens when changing the values and submitting them - they only update on the first view if “Done” is selected on the keyboard prior to selecting the Done button on the View.

As a test I downloaded the full code to check whether it was what I have done - but the code provided with the book has exactly the same behaviour. Has anyone else experienced this and can anyone point me in the right direction please?

Thanks, Simon

07 May 2009, 19:46
Biopic_100x100_pragsmall

Bill Dudney (917 posts)

Hi Simon,

That is because of the bug outlined here;

http://bill.dudney.net/roller/objc/entry/presenting_modal_views_bug

There is also a foot note explaining that you need to invoke the ‘view’ method on the editing view controller before you present it modally.

Hope this helps!

07 May 2009, 22:11
Generic-user-small

Simon Warbey (2 posts)

Hi Bill

That’s perfect - thank you.

Simon

08 May 2009, 22:31
Photo_1_pragsmall

Theron Daniel Huffman (12 posts)

The end of Chapter 3 is confusing and and the naming used when explaining the nib files in IB makes me wonder if it is not full of errors: MovieEditorView vs “MovieEditorViewController”. The Chapter ends as if the writer was tired of explaining the subject and wanted to get on to another subject as fast as possible. Needless to say, I couldn’t get the editor part of this project to work at all.

09 May 2009, 02:56
Biopic_100x100_pragsmall

Bill Dudney (917 posts)

Hi Theron,

Sorry you are having trouble with the chapter.

What exactly is giving you trouble. I’ll do my best to fix it.

09 May 2009, 23:51
Photo_1_pragsmall

Theron Daniel Huffman (12 posts)

Hello Bill, Thanks a lot for your prompt help.

Starting on page 67, creating the second view controller used to manage the modal view …

the names of the MovieEditorViewController class and the corresponding .xib file are confusing:

On page 70 it says to create a MovieEditorView.xib file but on page 75 the screenshot of the Nib Document Window shows “MovieEditorViewController” (Nowhere in the explanatiion does it say to create a MovieEditorViewController.xib).

Then on page 76 are screenshots of “MovieEditorViewController” AND “MovieEditorView”.

I was doing OK until page 67 then I more and more confused as I read on.

Regards,

11 May 2009, 01:33
Photo_1_pragsmall

Theron Daniel Huffman (12 posts)

Bill, Please disregard my previous comment (for a while at least). I went back and started reading Chapter 3 from the beginning and found that creating a MovieEditorViewController.xib IS INDEED mentioned.

My problem is that I divided Chapter 3 into 2 sessions and did the first part on one day and then a few days later did the second part (from page 67) about creating the second editor view controller.

Sorry for my lack of reading skills.

11 May 2009, 02:28
Biopic_100x100_pragsmall

Bill Dudney (917 posts)

Hi Theron,

No problem, I’m just glad you are making progress. Please ping me back if you discover any problems at all.

Good luck!

12 May 2009, 01:15
Photo_1_pragsmall

Theron Daniel Huffman (12 posts)

Hi Bill, Just to let you know…I went back and carefully redid the entire third chapter and it works just like you explained. There were a few mistakes that were already addressed in the errata. But MY problems were all of MY OWN making. Thanks for the great book.

12 May 2009, 02:32
Photo_1_pragsmall

Theron Daniel Huffman (12 posts)

I’m having one problem with the “textFieldDidEndEditing” method of MovieEditorViewController.m on page 69.

With the code as it is, In the running application, editing the value in boxOfficeGrossField UITextField causes a blank value to be displayed after pressing the Done button.

Why does commenting out the following line in the textFieldDidEndEditing method of MovieEditorViewController.m allow the edited value to be displayed? <pre>[formatter setNumberStyle:NSNumberFormatterCurrencyStyle];

12 May 2009, 02:53
Biopic_100x100_pragsmall

Bill Dudney (917 posts)

Hi Theron,

Glad you got it working!

The currency style requires the text typed in to be a valid currency amount.

So if a stray character (such as an ‘a’ or what not) gets into the text it will fail to parse. The error handling code is intentionally left out because it would confuse the main point.

Please ensure that you have not typed in some random characters and if not let me know and I’ll dig deeper into the problem.

Thanks again for the encouraging words here and on twitter!

12 May 2009, 05:31
Photo_1_pragsmall

Theron Daniel Huffman (12 posts)

It works like a charm if I follow your advice about entering a proper currency type amount. Thanks again.

19 May 2009, 22:06
Michaelc__small__pragsmall

Michael A Crawford (6 posts)

Well, I still don’t have Movie03 working. Would someone who has iPhone SDK Beta5 or better like to look over my project and tell me what I forgot or did wrong? When I click on the edit button the app crashes after the call to -[self presentModalViewController:self.editingViewController animated:YES]. I get the following exception:

[Session started at 2009-05-19 17:53:59 -0400.] 2009-05-19 17:54:02.572 Movie[9629:20b] *** Terminating app due to uncaught exception ‘NSUnknownKeyException’, reason: ‘[<MovieEditorViewController 0xd18a80> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key summaryLabel.’

The code for the summaryLabel property is generated for me and works just fine up to this point so I’m not sure what’s going on here. Here is the link to the project on my iDisk: http://files.me.com/michaelacrawford/mgrq92

20 May 2009, 07:42
Biopic_100x100_pragsmall

Bill Dudney (917 posts)

Hi Michael,

Sorry you are having trouble. The error message says that ‘movieeditorviewcontroller’ does not have a property ‘summaryLabel’. That means that in IB you made a connection from movieeditorviewcontroller to something via an IBOutlet called ‘summaryLabel’ then at some point down the road you renamed the IBOutlet to something else or deleted but did not use the refactoring support or deleted the outlet. If you load the nib files that have movieeditoryviewcontroller’s (the main nib file and the movieeditorviewcontroller are likely the only ones) you should see a yellow caution sign in the bottom left corner of the document window where the problem lies. Double click on that and it will take you to the problem. Or look at the connections inspector for the view controller (is the files owner in the movieeditorviewcontroller.xib) and delete the connection with the problem.

Good luck!

20 May 2009, 08:28
Biopic_100x100_pragsmall

Bill Dudney (917 posts)

Hi Michael,

I posted an extended write up on my blog;

http://bill.dudney.net/roller/objc/entry/nsunknownkeyexception

Hope it helps!

20 May 2009, 16:12
Michaelc__small__pragsmall

Michael A Crawford (6 posts)

Thanks, Bill.

07 Jun 2009, 03:39
Generic-user-small

Efram Burlingame (4 posts)

Hi Bill,

I am having difficulty with this final chapter 3 program also. I got it to compile and run on page 66, but I’m afraid that by page 76 I didn’t earn the “Fantastic!” as my program no longer functions correctly. The error in the debugger is “*** Terminating app due to uncaught exception ‘NSInternalInconsistencyException’, reason: ‘-[UIViewController loadView] loaded the “MovieEditorView” nib but no view was set.’”

I downloaded the .h and .m programs and found a couple of my errors, but I assume the issue is from section 3.7. In 3.7 you mention opening MovieViewController.xib but the picture shows MovieEditorViewController.xib. I don’t actually have that .xib. I think the errata mentions this, but even changing that doesnt seem to help. Any suggestions?

-thanks

edit: It would be nice if the final projects would be able to be downloaded also, that way I could check connections, .xib, etc.

07 Jun 2009, 11:19
Biopic_100x100_pragsmall

Bill Dudney (917 posts)

Hi Efram,

Sorry you are having trouble too, next beta should fix this issue.

As to your error message. That is most likely due to forgetting to set the view outlet in the MovieEditorView nib file. So open that file and connect the file’s owner to the view and it should fix your problem.

The code is (or should be) available at this link;

http://pragprog.com/titles/amiphd/source_code

Good luck!

08 Jun 2009, 05:44
Generic-user-small

Efram Burlingame (4 posts)

Thanks so much for the quick reply. What you said fixed it and I believe I have now earned the “Fantastic!” on page 76.

I would like to say that I bought the beta version off peoples recommendations on different forums. I have not been let down. I haven’t programmed since high school in ‘90 so there have been many innovations that have popped up since then (or at least from what I was taught). Your book is doing a great job in mixing learning, cheerleading, background information and examples. It seems writing a book like this (after looking at a couple of others) is no small feat. Thank you for making technical writing interesting.

-Efram

23 Jun 2009, 08:55
Skating_pragsmall

Jan-Helge Henriksen (3 posts)

Hello Bill. Great book!

I am having almost the same problem as Theron. The code line (page 73) self.movie.boxOfficeGross = [formatter numberFromString:self.boxOfficeGrossField.text]; works as it should when the regionformat is set to USA. Unfortunately it doesnt work when the regionformat is set to Sweden (both on thesimulator and Iphone 3G-3.0). The textfield is blank.

I used the log to check what was sent to the formatter: NSLog(@"Textfältets värde är %@", self.boxOfficeGrossField.text); which returned: Textfältets värde är 40 000,00 kr - which is correct. (I changed the first number from 3 to 4)

Is the formatter having problems with swedish kroner or am I doing something wrong here?

Best regards Jan-Helge Sweden

23 Jun 2009, 10:37
Biopic_100x100_pragsmall

Bill Dudney (917 posts)

Hi Jan-Helge,

For US locale you must place the currency sign, with no spaces, at the front of the amount. So perhaps the space is what’s causing the problem?

Also I suspect the space between the 40 and the 000 could also be causing problems.

Please let me know if these two spaces are causing the issue.

Thanks!

24 Jun 2009, 17:50
Skating_pragsmall

Jan-Helge Henriksen (3 posts)

Hello Bill, I made a little testprogram to check if the formatter could handle swedish kroner:

NSNumber *myNumber = [NSNumber numberWithDouble:100000.01];	
NSNumberFormatter *formatter = [[NSNumberFormatter alloc]init];
[formatter setFormatterBehavior:NSNumberFormatterBehavior10_4];
[formatter setNumberStyle:NSNumberFormatterCurrencyStyle];
NSString* formatted = [formatter stringFromNumber:myNumber];
	
NSLog(@"%@",formatted);
NSLog(@"%@",[formatter numberFromString:formatted]); 

The result:

2009-06-24 16:20:26.601 CurrencyTest[31633:10b] kr 100 000,01
2009-06-24 16:20:26.604 CurrencyTest[31633:10b] 100000.01

So the formatting is working both ways (from number to swedish kroner and back)

I belive the problem is in this row: self.movie.boxOfficeGross = [formatter numberFromString:self.boxOfficeGrossField.text]; and I believe that what I get from the textfield boxOfficeGrossField is not not behaving the way it should do. (my best guess)

I am glad if you have any idea why the code isn’t working when I switch the region (locale) to Sweden on the iPhone and the simulator.

Best Regards Jan Helge

24 Jun 2009, 18:21
Skating_pragsmall

Jan-Helge Henriksen (3 posts)

Hello again. In the routine - (void)textFieldDidEndEditing:(UITextField )textField, I did the following change: before: ~~~ NSNumberFormatter *formatter = [[NSNumberFormatter alloc]init]; [formatter setNumberStyle:NSNumberFormatterCurrencyStyle*]; ~~~

after:

NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init]; 
[formatter setNumberStyle:*NSNumberFormatterDecimalStyle*];

So far it’s working perfect :-)

Regards Jan Helge

06 Oct 2009, 10:00
Generic-user-small

David Mantripp (3 posts)

Hi,

I’m stuck here too. I’m using the final release of the book.

My problem is with the edit action:

the line: self.editingViewController = self.movie;

is generating an EXC_BAD_ACCESS signal. The debugger appears to be telling me that self.movie’s title is blank, boxOfficeGrosslabel is out of scope, and summary is invalid…

However the labels are displaying correctly in the initial view.

I know this isn’t much to go on, but any hints would be welcome!

Thank, David

06 Oct 2009, 11:50
Biopic_100x100_pragsmall

Bill Dudney (917 posts)

Hi David,

Did you get a chance to compare your code to the shipping sample code?

I think the line you call out above is the problem. You are assigning the editingViewController to the movie.

Please let me know when you get this figured out.

07 Oct 2009, 06:41
Generic-user-small

David Mantripp (3 posts)

Hi Bill,

Thanks for your reply. Unfortunately the missing .movie was just a typo in my post… I’m going to try to play around a bit with the movie class to see if I can work what I’ve done wrong…. (trouble is I’m trying to juggle about 3 completely different projects here, all with non-trivial learning curves :-) )

Thanks David

07 Oct 2009, 08:06
Generic-user-small

David Mantripp (3 posts)

Ok, user error :-)

Over-enthusiastic memory management on my part: in viewDidLoad I had this..

self.movie = newMovie; [newMovie release]

Oops. Sorry.

03 Apr 2013, 18:46
Generic-user-small

Satnam Sakhi (1 post)

Hello Bill, I’m new to iOS development, my friend recommended me to use your iPhone SDK book, I’m using latest version of XCode i.e. 4.6. I’m stuck on chapter 03 like others here. I’m trying to simulate this chapter’s code using Single View template, everything is exact copy of your code. I’m not sure what bit I’m missing but I’m getting following error. “Application tried to present a nil modal view controller on target “ Is the code that you’ve provided valid for current version of Xcode/iOS? I’ve tried various options and burned 2 nights (almost) but so far no luck. let me know if you’d want to see my version of code (assuming you’d need entire folder?)

Many thanks, Satnam Sakhi.

  You must be logged in to comment