简体   繁体   English

发现了旧的拼图样本苹果SDK

[英]Found the old jigsaw sample apple sdk

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:' 我收到错误:错误:'endTrackingPiece:position:'的参数2的不兼容类型错误:'continueTrackingPiece:position:'的参数2的不兼容的类型

- (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];

    //Continue 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: 这里的问题是locationInView期望将UIView *作为参数,请参见此处的参考:

http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UITouch_Class/Reference/Reference.html 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. 但是在此之前,如果引用的是Aspen1.2.sdk,则可能需要在项目文件中更改基本SDK,我找到的版本是。 I updated it to iOS4.3 (this is all in XCode 4, I should add.) 我将其更新为iOS4.3(这应该是XCode 4中的全部内容)。

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. 在AppController.m _resetPuzzle中。

After doing the above, I get a cleanly building project which runs in the iOS simulator. 完成上述操作后,我得到了一个干净的构建项目,该项目可以在iOS模拟器中运行。 Make sure you don't have your volume muted or you will miss the "Yay!" 确保您没有将音量静音,否则您会错过“是的!” when you complete a puzzle :) 当你完成一个难题时:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM