- (BOOL)version:(NSString *)_oldver lessthan:(NSString *)_newver //系統api { if ([_oldver compare:_newver option:NSNumbericSearch] == NSOrderedAscending) { return YES; } return NO; }
- (BOOL)version:(NSString *)_oldver lessthan:(NSString *)_newver { NSArray *a1 = [_oldver componentsSeparatedByString:@"."]; NSArray *a2 = [_newver componentsSeparatedByString:@"."]; for (int i = 0; i < [a1 count]; i++) { if ([a2 count] > i) { if ([[a1 objectAtIndex:i] floatValue] < [[a2 objectAtIndex:i] floatValue]) { return YES; } else if ([[a1 objectAtIndex:i] floatValue] > [[a2 objectAtIndex:i] floatValue]) { return NO; } } else { return NO; } } return [a1 count] < [a2 count]; }