好的,我对 Obj-C 和 iOS 完全陌生。我只是在 iOS 上尝试 Pebble 手表的 DataLogging 示例,并更改一些内容以记录加速度计读数。
我有这个功能:
- (BOOL)dataLoggingService:(PBDataLoggingService *)service hasByteArrays:(const UInt8 *const)data numberOfItems:(UInt16)numberOfItems forDataLoggingSession:(PBDataLoggingSessionMetadata *)sessionMetadata{
//NSString *log = [NSString stringWithFormat:@"%s", data]; <-- this line compiles but display garbage on the view. So I try to use the line below.
NSString *log = [[NSString alloc] initWithData:(NSData *)data encoding:NSASCIIStringEncoding]; <-- this line gave build error as in the post title
[self addLogLine:log];
// We consumed the data, let the data logging service know:
return YES;
}
因此,任何帮助将不胜感激。谢谢。