-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert
systemInfo
to a class and make systemInfoString
and `syst…
…emVersionString` instance properties
- Loading branch information
1 parent
2b0bcd4
commit b156e26
Showing
14 changed files
with
239 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
CSSystemInfoHelper/Headers/CSSystemInfoHelper/CSSystemInfo.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// | ||
// CSSystemInfo.h | ||
// CSSystemInfoHelper | ||
// | ||
// Created by Cătălin Stan on 18/06/2021. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
/// A container class for the @c utsname struct. | ||
/// See the @c uname(3) manual page for more info. | ||
@interface CSSystemInfo : NSObject | ||
|
||
/// Name of the operating system implementation. | ||
@property (nonatomic, readonly) NSString *sysName; | ||
|
||
/// Network name of this machine. | ||
@property (nonatomic, readonly) NSString *nodeName; | ||
|
||
/// Release level of the operating system. | ||
@property (nonatomic, readonly) NSString *releaseLevel; | ||
|
||
/// Version level of the operating system. | ||
@property (nonatomic, readonly) NSString *versionLevel; | ||
|
||
/// Machine hardware platform. | ||
@property (nonatomic, readonly) NSString *machine; | ||
|
||
/// A concatenated string representation of all the properties in the order | ||
/// listed in the @c uname(1) manual page. | ||
@property (nonatomic, readonly, strong) NSString *string; | ||
|
||
/// A concatenated string representation of the @c sysName, @c releaseLevel, | ||
/// properties @c machine, separated by space. | ||
@property (nonatomic, readonly, strong) NSString *versionString; | ||
|
||
+ (instancetype)new NS_UNAVAILABLE; | ||
- (instancetype)init NS_UNAVAILABLE; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// | ||
// CSSystemInfo+Internal.h | ||
// CSSystemInfoHelper | ||
// | ||
// Created by Cătălin Stan on 18/06/2021. | ||
// | ||
|
||
#import <CSSystemInfoHelper/CSSystemInfo.h> | ||
|
||
#import <sys/utsname.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface CSSystemInfo () | ||
|
||
- (instancetype)initWithSysName:(NSString *)sysName | ||
nodeName:(NSString *)nodeName | ||
releaseLevel:(NSString *)releaseLevel | ||
versionLevel:(NSString *)versionLevel | ||
machine:(NSString *)machine | ||
NS_DESIGNATED_INITIALIZER; | ||
|
||
- (instancetype)initWithUtsnameStruct:(struct utsname *)utsnameStruct; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// | ||
// CSSystemInfo.m | ||
// CSSystemInfoHelper | ||
// | ||
// Created by Cătălin Stan on 18/06/2021. | ||
// | ||
|
||
#import <CSSystemInfoHelper/CSSystemInfo.h> | ||
#import "CSSystemInfo+Internal.h" | ||
|
||
@implementation CSSystemInfo | ||
|
||
- (instancetype)initWithUtsnameStruct:(struct utsname *)utsnameStruct { | ||
return [self initWithSysName:@(utsnameStruct->sysname) | ||
nodeName:@(utsnameStruct->nodename) | ||
releaseLevel:@(utsnameStruct->release) | ||
versionLevel:@(utsnameStruct->version) | ||
machine:@(utsnameStruct->machine)]; | ||
} | ||
|
||
- (instancetype)initWithSysName:(NSString *)sysName | ||
nodeName:(NSString *)nodeName | ||
releaseLevel:(NSString *)releaseLevel | ||
versionLevel:(NSString *)versionLevel | ||
machine:(NSString *)machine { | ||
self = [super init]; | ||
if (self) { | ||
_sysName = sysName; | ||
_nodeName = nodeName; | ||
_releaseLevel = releaseLevel; | ||
_versionLevel = versionLevel; | ||
_machine = machine; | ||
|
||
_string = [NSString stringWithFormat:@"%@ %@ %@ %@ %@", _sysName, _nodeName, _releaseLevel, _versionLevel, _machine]; | ||
_versionString = [NSString stringWithFormat:@"%@ %@ %@", _sysName, _releaseLevel, _machine]; | ||
} | ||
return self; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.