Pet*_*erK 1 iphone objective-c uniqueidentifier cocos2d-iphone
我在网上搜索了答案并找到了不少解决方案,但不得不承认我并不理解,因为我很新,如何应用答案,一个例子是:UIDevice uniqueIdentifier已弃用 - 现在该怎么办?
我真的很感激,如果有人可以向我展示如何在下面的代码中将解决方案应用于该问题的示例,因为不推荐使用以下行(uniqueIdentifier),代码行来自Cocos2d CLScoreServerRequest.m,但是在其他几个中出现了好:
device = [[UIDevice currentDevice] uniqueIdentifier];
Run Code Online (Sandbox Code Playgroud)
该功能如下:
-(BOOL) requestScores:(tQueryType)type
limit:(int)limit
offset:(int)offset
flags:(tQueryFlags)flags
category:(NSString*)category
{
// create the request
[receivedData setLength:0];
// it's not a call for rank
reqRankOnly = NO;
NSString *device = @"";
if( flags & kQueryFlagByDevice )
device = [[UIDevice currentDevice] uniqueIdentifier];
// arguments:
// query: type of query
// limit: how many scores are being requested. Default is 25. Maximun is 100
// offset: offset of the scores
// flags: bring only country scores, world scores, etc.
// category: string user defined string used to filter
NSString *url= [NSString stringWithFormat:@"%@?gamename=%@&querytype=%d&offset=%d&limit=%d&flags=%d&category=%@&device=%@",
SCORE_SERVER_REQUEST_URL,
gameName,
type,
offset,
limit,
flags,
[category stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding],
device
];
// NSLog(@"%@", url);
NSURLRequest *request=[NSURLRequest requestWithURL:[NSURL URLWithString:url]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
// create the connection with the request
// and start loading the data
self.connection=[NSURLConnection connectionWithRequest:request delegate:self];
if (! connection_)
return NO;
return YES;
}
Run Code Online (Sandbox Code Playgroud)
这是快速简单的解决方案:
将项目(或目标)的部署目标更改为iOS 4.x或更低版本.在这种情况下,编译器仍会发出警告,但它只是一个警告.仅当您的部署针对iOS 5.0或更高版本时,编译器才会生成有关已弃用方法的错误.
至于Cocos2D源代码中的警告,请忽略这些警告,直到下一个Cocos2D官方发布版修复该问题.