Amazon.com Widgets Exercise 15-2 Thought I had the solution, but, wait, not so fast ... weird.
Welcome, Guest. Please login or register.
Did you miss your activation email?
June 20, 2013, 06:32:15 AM
Home Help Search chat Login Register   
News: Read this please.The Great Kangaroo Escape Looking for reviews of the 4th ed on Amazon!   Twitter:  @skochan
                     

+  Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
|-+  Programming in Objective-C, 4th edition
| |-+  Chapter 15
| | |-+  Exercise 15-2 Thought I had the solution, but, wait, not so fast ... weird.
Pages: [1]   Go Down
Print
Author Topic: Exercise 15-2 Thought I had the solution, but, wait, not so fast ... weird.  (Read 379 times)
bitshifter
Newbie
*
Posts: 9







« on: May 22, 2012, 04:42:15 PM »

Thought I had 15-2 worked out. Starting with Stephen's code in the chapter that uses indexOfObjectPassingTest:, I thought, just change the comparison to find a substring match and you're there. And that seemed to work. Compiles without errors and runs to completion. But then I happened to run it multiple times in a row, and after about 5 or 6 consecutive runs (or sometimes it takes 20), a strange thing starts to happen. The program starts exiting early. No errors or crashes. It exits with code 0, but it exits early and not always at the same point. It all seems random. Cleaning does not seem to help. So, I tried going back to the lookup method exactly as it is presented in the book just to make sure that works, and I still see the same odd behavior. I'm not really sure what code to post here. The lookup method is as presented in the book. In main I am simply using it like this:
Code: (Objective-C)
[[myBook lookup:@"Stephen Kochan"] print];
Maybe the most useful thing is a view of the output. I've attempted to attach a screen capture of the output window as I run the program about 17 times consecutively. You will see that it exits early about 4 or 5 times and not always at the same point.

http://youtu.be/scrWxtryw8Q

So maybe the first question is, for those of you who have this working, if you run the program many times consecutively (which you may not have done before), does anyone see this anomaly? If I had only run this once or twice, I could have easily called it good and moved on, but now I am quite stumped.
Logged
bitshifter
Newbie
*
Posts: 9







« Reply #1 on: May 22, 2012, 04:47:21 PM »

I should add that you will see some extra output from some NSLog statements inserted for debugging. It's fairly self-explanatory.
Logged
Pages: [1]   Go Up
Print
Jump to:  



Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Entire forum contents (c) 2009 classroomM.com. All rights reserved.