1

我正在使用 Shuttle Magstripe 阅读器,并将响应转换[notification object]为 NSData,然后将其转换为 NSString

NSData* data = [notification object];
NSString* response = [[NSString alloc] initWithData: data encoding:NSASCIIStringEncoding];

但是当我尝试NSLog(@"RESPONSE: %@", response);

输出只是?关于如何正确处理 Shuttle MagStripe 阅读器的滑动响应的任何想法?

4

1 回答 1

1

试试这种方式,将信息传递为

 NSDictionary *userInfo = [NSDictionary dictionaryWithObject:<#yourNSDataObject> forKey:@"pass"];
   [[NSNotificationCenter defaultCenter] postNotificationName:@"myevent" object:nil userInfo:userInfo];

并在接收器方法上获取对象

- (void)receiveEvent:(NSNotification *)notification {
    NSData pass = [[notification userInfo] valueForKey:@"pass"];
}
于 2013-01-10T05:54:41.777 回答