maybe not a more elegant solution, but it definitely does the job, so you can try something like this in ObjC:
- (NumVersion)systemVersion { NSArray *_separated = [[[UIDevice currentDevice] systemVersion] componentsSeparatedByString:@"."]; NumVersion _version = { 0, 0, 0, 0 }; if (_separated.count > 3) _version.stage = [[_separated objectAtIndex:3] integerValue]; if (_separated.count > 2) _version.nonRelRev = [[_separated objectAtIndex:2] integerValue]; if (_separated.count > 1) _version.minorAndBugRev = [[_separated objectAtIndex:1] integerValue]; if (_separated.count > 0) _version.majorRev = [[_separated objectAtIndex:0] integerValue]; return _version; }
then
NumVersion version = [self systemVersion]; NSLog(@"%d, %d, %d, %d", version.majorRev, version.minorAndBugRev, version.nonRelRev, version.stage);
will print (in my case at the very moment):
11, 0, 2, 0
what you could convert to a more desirable format for your analytics.
source share