mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-13 19:22:25 +00:00
use class properties
This commit is contained in:
20
MacPass/MPPluginRepositoryItemVersionInfo.h
Normal file
20
MacPass/MPPluginRepositoryItemVersionInfo.h
Normal file
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// MPPluginVersionInfo.h
|
||||
// MacPass
|
||||
//
|
||||
// Created by Michael Starke on 04.10.18.
|
||||
// Copyright © 2018 HicknHack Software GmbH. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface MPPluginRepositoryItemVersionInfo : NSObject
|
||||
|
||||
- (instancetype)initWithDict:(NSDictionary *)dict NS_DESIGNATED_INITIALIZER;
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
36
MacPass/MPPluginRepositoryItemVersionInfo.m
Normal file
36
MacPass/MPPluginRepositoryItemVersionInfo.m
Normal file
@@ -0,0 +1,36 @@
|
||||
//
|
||||
// MPPluginVersionInfo.m
|
||||
// MacPass
|
||||
//
|
||||
// Created by Michael Starke on 04.10.18.
|
||||
// Copyright © 2018 HicknHack Software GmbH. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MPPluginRepositoryItemVersionInfo.h"
|
||||
|
||||
NSString *const MPPluginItemCompatibiltyVersionKey = @"pluginVersion";
|
||||
NSString *const MPPluginItemCompatibiltyMinimumHostVersionKey = @"minimumHostVersion";
|
||||
NSString *const MPPluginItemCompatibiltyMaxiumumHostVersionKey = @"maxiumumHostVersion";
|
||||
|
||||
@interface MPPluginRepositoryItemVersionInfo ()
|
||||
|
||||
@property (copy) NSString *version;
|
||||
@property (copy) NSString *minimumHostVersion;
|
||||
@property (copy) NSString *maxiumHostVersion;
|
||||
|
||||
|
||||
@end
|
||||
|
||||
@implementation MPPluginRepositoryItemVersionInfo
|
||||
|
||||
- (instancetype)initWithDict:(NSDictionary *)dict {
|
||||
self = [super init];
|
||||
if(self) {
|
||||
self.version = dict[MPPluginItemCompatibiltyVersionKey];
|
||||
self.minimumHostVersion = dict[MPPluginItemCompatibiltyMinimumHostVersionKey];
|
||||
self.maxiumHostVersion = dict[MPPluginItemCompatibiltyMaxiumumHostVersionKey];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -25,7 +25,7 @@
|
||||
@implementation NSApplication (MPAdditions)
|
||||
|
||||
- (NSString *)applicationName {
|
||||
return [[NSBundle mainBundle].infoDictionary[@"CFBundleName"] copy];
|
||||
return [NSBundle.mainBundle.infoDictionary[@"CFBundleName"] copy];
|
||||
}
|
||||
|
||||
- (NSURL *)applicationSupportDirectoryURL {
|
||||
@@ -34,18 +34,18 @@
|
||||
|
||||
- (NSURL *)applicationSupportDirectoryURL:(BOOL)create {
|
||||
NSError *error;
|
||||
NSURL *url = [[NSFileManager defaultManager] URLForDirectory:NSApplicationSupportDirectory
|
||||
inDomain:NSUserDomainMask
|
||||
appropriateForURL:nil
|
||||
create:NO
|
||||
error:&error];
|
||||
NSURL *url = [NSFileManager.defaultManager URLForDirectory:NSApplicationSupportDirectory
|
||||
inDomain:NSUserDomainMask
|
||||
appropriateForURL:nil
|
||||
create:NO
|
||||
error:&error];
|
||||
if(url) {
|
||||
url = [url URLByAppendingPathComponent:self.applicationName isDirectory:YES];
|
||||
if(create) {
|
||||
[[NSFileManager defaultManager] createDirectoryAtURL:url
|
||||
withIntermediateDirectories:YES
|
||||
attributes:nil
|
||||
error:&error];
|
||||
[NSFileManager.defaultManager createDirectoryAtURL:url
|
||||
withIntermediateDirectories:YES
|
||||
attributes:nil
|
||||
error:&error];
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user