Skip to content

Commit

Permalink
feat(ios): add Ti.Platform.versionPatch
Browse files Browse the repository at this point in the history
Fixes TIMOB-28098
  • Loading branch information
sgtcoolguy committed Aug 31, 2020
1 parent 14a5e5b commit a78e9cc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
1 change: 1 addition & 0 deletions iphone/Classes/PlatformModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ READONLY_PROPERTY(NSString *, username, Username);
READONLY_PROPERTY(NSString *, version, Version);
READONLY_PROPERTY(NSNumber *, versionMajor, VersionMajor);
READONLY_PROPERTY(NSNumber *, versionMinor, VersionMinor);
READONLY_PROPERTY(NSNumber *, versionPatch, VersionPatch);

// Methods
- (BOOL)canOpenURL:(NSString *)url;
Expand Down
21 changes: 14 additions & 7 deletions iphone/Classes/PlatformModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,30 @@

@implementation PlatformModule

@synthesize architecture, availableMemory, model, name, osname, ostype, processorCount, totalMemory, uptime, username, version, versionMajor, versionMinor;
@synthesize architecture, availableMemory, model, name, osname, ostype, processorCount, totalMemory, uptime, username, version, versionMajor, versionMinor, versionPatch;

#pragma mark Internal

- (id)init
{
if (self = [super init]) {
UIDevice *theDevice = [UIDevice currentDevice];
name = [[theDevice systemName] retain];
version = [[theDevice systemVersion] retain];
UIDevice *theDevice = UIDevice.currentDevice;
name = [theDevice.systemName retain];
version = [theDevice.systemVersion retain];

// Extract "<major>.<minor>" integers from OS version string.
NSArray *versionComponents = [version componentsSeparatedByString:@"."];
versionMajor = [NSNumber numberWithInt:[versionComponents[0] intValue]];
if ([versionComponents count] >= 2) {
versionMinor = [NSNumber numberWithInt:[versionComponents[1] intValue]];
if ([versionComponents count] >= 3) {
versionPatch = [NSNumber numberWithInt:[versionComponents[2] intValue]];
} else {
versionPatch = @0;
}
} else {
versionMinor = @0;
versionPatch = @0;
}

// grab logical CPUs
Expand All @@ -58,7 +64,7 @@ - (id)init
}
processorCount = [[NSNumber numberWithInt:cores] retain];

username = [[theDevice name] retain];
username = [theDevice.name retain];
#ifdef __LP64__
ostype = [@"64bit" retain];
#else
Expand All @@ -73,7 +79,7 @@ - (id)init
osname = [@"iphone" retain];
}

NSString *themodel = [theDevice model];
NSString *themodel = theDevice.model;

// attempt to determine extended phone info
struct utsname u;
Expand All @@ -88,7 +94,7 @@ - (id)init
architecture = [[TiUtils currentArchitecture] retain];

// needed for platform displayCaps orientation to be correct
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[theDevice beginGeneratingDeviceOrientationNotifications];
}
return self;
}
Expand All @@ -100,6 +106,7 @@ - (void)dealloc
RELEASE_TO_NIL(version);
RELEASE_TO_NIL(versionMajor);
RELEASE_TO_NIL(versionMinor);
RELEASE_TO_NIL(versionPatch);
RELEASE_TO_NIL(architecture);
RELEASE_TO_NIL(processorCount);
RELEASE_TO_NIL(username);
Expand Down

0 comments on commit a78e9cc

Please sign in to comment.