I just come across the old jigsaw source that apple used to have on offer. Ive got a few errors when compling just wondered if anyone could help.
I get the error: error: incompatible type for argument 2 of 'endTrackingPiece:position:' error: incompatible type for argument 2 of 'continueTrackingPiece:position:'
- (void) touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event
{
UITouch* touch = [touches anyObject];
//Check if we have a double-tap in the piece view and notify the application controller or begin tracking piece dragging
if([touch tapCount] >= 2)
[(AppController*)[[UIApplication sharedApplication] delegate] resetPiece:self];
else {
_tracking = YES;
[(AppController*)[[UIApplication sharedApplication] delegate] beginTrackingPiece:self position:[touch locationInView]];
}
}
- (void) touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event
{
UITouch* touch = [touches anyObject];
//Con开发者_StackOverflow社区tinue tracking piece dragging
if(_tracking)
[(AppController*)[[UIApplication sharedApplication] delegate] continueTrackingPiece:self position:[touch locationInView]];
}
- (void) touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event
{
UITouch* touch = [touches anyObject];
//Finish tracking piece dragging
if(_tracking) {
[(AppController*)[[UIApplication sharedApplication] delegate] endTrackingPiece:self position:[touch locationInView]];
_tracking = NO;
}
}
Thanks in advance
The problem here is that locationInView is expecting a UIView * as a parameter, see reference here:
http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UITouch_Class/Reference/Reference.html
So, for each of those three lines, the fix is to change
[touch locationInView]
to
[touch locationInView: self]
Prior to this though, you may need to change the base SDK in the project file, if it's referring to Aspen1.2.sdk, the version I found is. I updated it to iOS4.3 (this is all in XCode 4, I should add.)
If you want to get rid of the deprecation warning as well, change
_puzzles = [[[NSFileManager defaultManager] directoryContentsAtPath:path] mutableCopy];
to
_puzzles = [[[NSFileManager defaultManager] contentsOfDirectoryAtPath:path error:NULL] mutableCopy];
in AppController.m _resetPuzzle.
After doing the above, I get a cleanly building project which runs in the iOS simulator. Make sure you don't have your volume muted or you will miss the "Yay!" when you complete a puzzle :)
精彩评论