
NSNumber and NSDictionary are the basic class and most useful class in objective c.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
- (void) dataDownloadAtPercent:(PvUrlSessionDownload*)downloader withVid:(NSString *)vid percent: (NSNumber *) aPercent{ if(nil == map){ map = [NSMutableDictionary dictionaryWithCapacity:10]; } dispatch_async(dispatch_get_main_queue(), ^{ int x = 0; int y = [aPercent intValue]; if(nil == [map objectForKey:vid]){ [map setObject:[[NSNumber alloc] initWithInt:y] forKey:vid]; } else{ if([[map objectForKey:vid] isKindOfClass:[NSNumber class]]){ x = [[map objectForKey:vid] intValue]; } } RCTLogInfo(@"来自Xcode的信息-下载了:%@|%d|%d",aPercent,y,x); if(x!=y){ [map setObject:[[NSNumber alloc] initWithInt:y] forKey:vid]; [self.bridge.eventDispatcher sendAppEventWithName:@"DownloadEvent" body:@{@"what": @4, @"status": [NSNumber numberWithInt:y], @"name": @"downloadAtPercent", @"vid":vid}]; }
}); }
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
NSNumber * intNumber = [[NSNumber alloc] initWithInt:5]; NSNumber * floatNumber = [[NSNumber alloc] initWithFloat:3.14f]; NSNumber * doubleNumber = [[NSNumber alloc] initWithDouble:6.7]; NSNumber * charNumber = [[NSNumber alloc] initWithChar:'A'];
BOOL ret = [intNumber isEqualToNumber:intNumber2];
if ([intNumber compare:intNumber] == NSOrderedAscending) { NSLog(@"<"); }else if([intNumber compare:intNumber2] == NSOrderedSame){ NSLog(@"="); }else if([intNumber compare:intNumber2] == NSOrderedDescending){ NSLog(@">"); }
NSLog(@"%d", [intNumber intValue]); NSLog(@"%f", [floatNumber floatValue]); NSLog(@"%f", [doubleNumber doubleValue]); NSLog(@"%c", [charNumber charValue]);
|
近期评论