Wrox Programmer Forums
|
BOOK: Professional iPhone and iPad Application Development
This is the forum to discuss the Wrox book Professional iPhone and iPad Application Development by Gene Backlin; ISBN: 978-0-470-87819-4
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional iPhone and iPad Application Development section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 14th, 2011, 02:44 PM
Friend of Wrox
 
Join Date: Aug 2010
Posts: 298
Thanks: 1
Thanked 62 Times in 60 Posts
Default Chapter 5

A few opinions.
1. In the handleSwipeEvent: method it makes more sense to me to make CGPoint location the [self.imageView center] as the starting point rather than the [recognizer locationInView:self], unless the recognizer is within the bounds of the imageView. It is rather strange, when the swipe is initiated outside of the image, for the image to jump first to the touch point and then slide.

2. In handleRotateEvent I think it is useful to add
Code:
if ([recognizer state] == UIGestureRecognizerStateEnded)
before the animation block. This allows the rotated position to remain until the touch is released. As written, if the rotation pauses the image begins to fall back to its initial state. Then if the rotation resumes it jumps back to the previous rotation, and continues rotating. Also, without this call my attempts to rewrite the animation block with [UIView animateWithDuration…] produced very bizarre results.
For those interested in how this method is redone using blocks, this is what I did

Code:
-(void)handleRotateEvent:(UIRotationGestureRecognizer *)recognizer
{
 
    [self updateDisplayValuesWithPhase:@"handleRotateEvent" tapCount:1 touchCount:2];
    
    CGPoint location = [recognizer locationInView:self];
  
    [self.imageView setTransform:CGAffineTransformMakeRotation([recognizer rotation])];
    [self.imageView setCenter:location];

     if ([recognizer state] == UIGestureRecognizerStateEnded)
     {
     /*    
         [UIView beginAnimations:nil context:nil];
         [UIView setAnimationDuration:.5];
         [self.imageView setTransform:CGAffineTransformIdentity];
         [UIView commitAnimations];
       */   

         [UIView animateWithDuration:.5 animations:^{[self.imageView setTransform:CGAffineTransformIdentity];}];
    }
}
Two minor points:
1. on p. 185 and 196 in the loadShake method The NSLog should be
Code:
NSLog(@"Error %ld loading sound at path: %@", error, path);
since using just %d generates a warning
2. A couple of methods only appear in the complete listing. -(void)resetImageInView, -(BOOL)shouldAutoRotate… and -(void)dealloc, not as separate entries, so when the text states the the .m is now complete, be sure to consult the full listing and include these methods.

Lastly a question. Sometimes in the [UIView beginAnimations:context:] sometimes nil is used and sometimes NULL. They are essentially the same, correct? and interchangeable. (My internet research brought up some issues about nil - Objective C object and NIL Objective C class and NULL all others.) Does it really matter?
Bob
 
Old March 14th, 2011, 11:14 PM
Wrox Author
 
Join Date: Oct 2010
Posts: 61
Thanks: 0
Thanked 9 Times in 7 Posts
Default

Quote:
Originally Posted by thepianoguy View Post
A few opinions.
Lastly a question. Sometimes in the [UIView beginAnimations:context:] sometimes nil is used and sometimes NULL. They are essentially the same, correct? and interchangeable. (My internet research brought up some issues about nil - Objective C object and NIL Objective C class and NULL all others.) Does it really matter?
Bob
You would think so, however I have run a case where I am making a REST call to a java based server. Sometimes they will return 0 and I check to see if the object is nil

Code:
    if (returnCode != nil) {
However sometimes they will make the object null and the above check would not work, so I had to do the following:

Code:
    if (returnCode != (NSString *)[NSNull null]) {
Traditionally in the NeXT days, all that I used was nil.

Take Care,
Gene





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 6 - Code Download Missing for this Chapter dbaechtel BOOK: Professional SharePoint 2007 Development ISBN: 978-0-470-11756-9 0 August 11th, 2009 11:02 AM
Chapter 2 - End of chapter exercises whizzkid1892 BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 1 July 30th, 2008 12:02 PM
Generics chapter 12 difficult chapter i found ...? Larryz C# 2005 1 July 4th, 2007 09:40 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.