Skip to content

Commit

Permalink
Switch to standard singleton code.
Browse files Browse the repository at this point in the history
  • Loading branch information
kstenerud committed Dec 1, 2016
1 parent b87c43e commit 81ccec2
Show file tree
Hide file tree
Showing 15 changed files with 83 additions and 139 deletions.
6 changes: 0 additions & 6 deletions Mac/KSCrash-Mac.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@
CB62410D17EBCA74006471F1 /* KSHTTPRequestSender.m in Sources */ = {isa = PBXBuildFile; fileRef = CB8E56DA17EB9B89000C56D3 /* KSHTTPRequestSender.m */; };
CB62410E17EBCA74006471F1 /* KSReachabilityKSCrash.h in Headers */ = {isa = PBXBuildFile; fileRef = CB8E56DB17EB9B89000C56D3 /* KSReachabilityKSCrash.h */; settings = {ATTRIBUTES = (Private, ); }; };
CB62410F17EBCA74006471F1 /* KSReachabilityKSCrash.m in Sources */ = {isa = PBXBuildFile; fileRef = CB8E56DC17EB9B89000C56D3 /* KSReachabilityKSCrash.m */; };
CB62411017EBCA74006471F1 /* KSSingleton.h in Headers */ = {isa = PBXBuildFile; fileRef = CB8E56DD17EB9B89000C56D3 /* KSSingleton.h */; settings = {ATTRIBUTES = (Private, ); }; };
CB62411117EBCA74006471F1 /* KSVarArgs.h in Headers */ = {isa = PBXBuildFile; fileRef = CB8E56DE17EB9B89000C56D3 /* KSVarArgs.h */; };
CB62411217EBCA74006471F1 /* NSData+GZip.h in Headers */ = {isa = PBXBuildFile; fileRef = CB8E56DF17EB9B89000C56D3 /* NSData+GZip.h */; };
CB62411317EBCA74006471F1 /* NSData+GZip.m in Sources */ = {isa = PBXBuildFile; fileRef = CB8E56E017EB9B89000C56D3 /* NSData+GZip.m */; };
Expand Down Expand Up @@ -308,7 +307,6 @@
CB8E56F017EB9B89000C56D3 /* KSHTTPRequestSender.m in Sources */ = {isa = PBXBuildFile; fileRef = CB8E56DA17EB9B89000C56D3 /* KSHTTPRequestSender.m */; };
CB8E56F117EB9B89000C56D3 /* KSReachabilityKSCrash.h in Headers */ = {isa = PBXBuildFile; fileRef = CB8E56DB17EB9B89000C56D3 /* KSReachabilityKSCrash.h */; settings = {ATTRIBUTES = (Private, ); }; };
CB8E56F217EB9B89000C56D3 /* KSReachabilityKSCrash.m in Sources */ = {isa = PBXBuildFile; fileRef = CB8E56DC17EB9B89000C56D3 /* KSReachabilityKSCrash.m */; };
CB8E56F317EB9B89000C56D3 /* KSSingleton.h in Headers */ = {isa = PBXBuildFile; fileRef = CB8E56DD17EB9B89000C56D3 /* KSSingleton.h */; settings = {ATTRIBUTES = (Private, ); }; };
CB8E56F417EB9B89000C56D3 /* KSVarArgs.h in Headers */ = {isa = PBXBuildFile; fileRef = CB8E56DE17EB9B89000C56D3 /* KSVarArgs.h */; };
CB8E56F517EB9B89000C56D3 /* NSData+GZip.h in Headers */ = {isa = PBXBuildFile; fileRef = CB8E56DF17EB9B89000C56D3 /* NSData+GZip.h */; settings = {ATTRIBUTES = (Public, ); }; };
CB8E56F617EB9B89000C56D3 /* NSData+GZip.m in Sources */ = {isa = PBXBuildFile; fileRef = CB8E56E017EB9B89000C56D3 /* NSData+GZip.m */; };
Expand Down Expand Up @@ -555,7 +553,6 @@
CB8E56DA17EB9B89000C56D3 /* KSHTTPRequestSender.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = KSHTTPRequestSender.m; path = ../../Source/KSCrash/Reporting/Tools/KSHTTPRequestSender.m; sourceTree = "<group>"; };
CB8E56DB17EB9B89000C56D3 /* KSReachabilityKSCrash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KSReachabilityKSCrash.h; path = ../../Source/KSCrash/Reporting/Tools/KSReachabilityKSCrash.h; sourceTree = "<group>"; };
CB8E56DC17EB9B89000C56D3 /* KSReachabilityKSCrash.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = KSReachabilityKSCrash.m; path = ../../Source/KSCrash/Reporting/Tools/KSReachabilityKSCrash.m; sourceTree = "<group>"; };
CB8E56DD17EB9B89000C56D3 /* KSSingleton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KSSingleton.h; path = ../../Source/KSCrash/Recording/Tools/KSSingleton.h; sourceTree = "<group>"; };
CB8E56DE17EB9B89000C56D3 /* KSVarArgs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KSVarArgs.h; path = ../../Source/KSCrash/Reporting/Filters/Tools/KSVarArgs.h; sourceTree = "<group>"; };
CB8E56DF17EB9B89000C56D3 /* NSData+GZip.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSData+GZip.h"; path = "../../Source/KSCrash/Reporting/Filters/Tools/NSData+GZip.h"; sourceTree = "<group>"; };
CB8E56E017EB9B89000C56D3 /* NSData+GZip.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "NSData+GZip.m"; path = "../../Source/KSCrash/Reporting/Filters/Tools/NSData+GZip.m"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -967,7 +964,6 @@
CB8E567017EB9B43000C56D3 /* KSObjCApple.h */,
CB8E567317EB9B43000C56D3 /* KSSignalInfo.c */,
CB8E567417EB9B43000C56D3 /* KSSignalInfo.h */,
CB8E56DD17EB9B89000C56D3 /* KSSingleton.h */,
CB8E567517EB9B43000C56D3 /* KSString.c */,
CB8E567617EB9B43000C56D3 /* KSString.h */,
CB8E567717EB9B43000C56D3 /* KSSysCtl.c */,
Expand Down Expand Up @@ -1101,7 +1097,6 @@
CB6240D117EBCA74006471F1 /* KSLogger.h in Headers */,
CBBD3AA91CAD989400DBB897 /* KSCrashReportFilterStringify.h in Headers */,
CB6240E317EBCA74006471F1 /* KSSysCtl.h in Headers */,
CB62411017EBCA74006471F1 /* KSSingleton.h in Headers */,
CB2686191C694E4400EE4EB3 /* AlignOf.h in Headers */,
CB6240BB17EBCA74006471F1 /* KSCrashSentry_Deadlock.h in Headers */,
CB62411617EBCA74006471F1 /* NSError+SimpleConstructor.h in Headers */,
Expand Down Expand Up @@ -1201,7 +1196,6 @@
CB8E568617EB9B43000C56D3 /* KSJSONCodecObjC.h in Headers */,
CB8E564E17EB9B35000C56D3 /* KSCrashSentry_CPPException.h in Headers */,
CB8E568117EB9B43000C56D3 /* KSBacktrace_Private.h in Headers */,
CB8E56F317EB9B89000C56D3 /* KSSingleton.h in Headers */,
CBBD3AA81CAD989400DBB897 /* KSCrashReportFilterStringify.h in Headers */,
CB8E568517EB9B43000C56D3 /* KSJSONCodec.h in Headers */,
CB8E565017EB9B35000C56D3 /* KSCrashSentry_Deadlock.h in Headers */,
Expand Down
14 changes: 11 additions & 3 deletions Source/KSCrash/Installations/KSCrashInstallationConsole.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,22 @@
#import "KSCrashReportFilterAppleFmt.h"
#import "KSCrashReportFilterJSON.h"
#import "KSCrashReportFilterStringify.h"
#import "KSSingleton.h"

@implementation KSCrashInstallationConsole

IMPLEMENT_EXCLUSIVE_SHARED_INSTANCE(KSCrashInstallationConsole)

@synthesize printAppleFormat = _printAppleFormat;

+ (instancetype) sharedInstance
{
static KSCrashInstallationConsole *sharedInstance = nil;
static dispatch_once_t onceToken;

dispatch_once(&onceToken, ^{
sharedInstance = [[KSCrashInstallationConsole alloc] init];
});
return sharedInstance;
}

- (id) init
{
if((self = [super initWithRequiredProperties:nil]))
Expand Down
2 changes: 1 addition & 1 deletion Source/KSCrash/Installations/KSCrashInstallationEmail.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,6 @@ typedef enum
- (void) setReportStyle:(KSCrashEmailReportStyle)reportStyle
useDefaultFilenameFormat:(BOOL) useDefaultFilenameFormat;

+ (KSCrashInstallationEmail*) sharedInstance;
+ (instancetype) sharedInstance;

@end
14 changes: 11 additions & 3 deletions Source/KSCrash/Installations/KSCrashInstallationEmail.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
#import "KSCrashInstallation+Private.h"
#import "KSCrashReportSinkEMail.h"
#import "KSCrashReportFilterAlert.h"
#import "KSSingleton.h"


@interface KSCrashInstallationEmail ()
Expand All @@ -41,15 +40,24 @@ @interface KSCrashInstallationEmail ()

@implementation KSCrashInstallationEmail

IMPLEMENT_EXCLUSIVE_SHARED_INSTANCE(KSCrashInstallationEmail)

@synthesize recipients = _recipients;
@synthesize subject = _subject;
@synthesize message = _message;
@synthesize filenameFmt = _filenameFmt;
@synthesize reportStyle = _reportStyle;
@synthesize defaultFilenameFormats = _defaultFilenameFormats;

+ (instancetype) sharedInstance
{
static KSCrashInstallationEmail *sharedInstance = nil;
static dispatch_once_t onceToken;

dispatch_once(&onceToken, ^{
sharedInstance = [[KSCrashInstallationEmail alloc] init];
});
return sharedInstance;
}

- (id) init
{
if((self = [super initWithRequiredProperties:[NSArray arrayWithObjects:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,6 @@
/** App identifier you received from Hockey (mandatory) */
@property(nonatomic, readwrite, retain) NSString* appIdentifier;

+ (KSCrashInstallationHockey*) sharedInstance;
+ (instancetype) sharedInstance;

@end
34 changes: 23 additions & 11 deletions Source/KSCrash/Installations/KSCrashInstallationQuincyHockey.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#import "KSCrashInstallation+Private.h"
#import "KSCrashReportFields.h"
#import "KSCrashReportSinkQuincyHockey.h"
#import "KSSingleton.h"
#import "NSError+SimpleConstructor.h"


Expand Down Expand Up @@ -84,18 +83,22 @@ - (NSArray*) allCrashDescriptionKeys

@implementation KSCrashInstallationQuincy

IMPLEMENT_EXCLUSIVE_SHARED_INSTANCE(KSCrashInstallationQuincy)

@synthesize url = _url;

+ (instancetype) sharedInstance
{
static KSCrashInstallationQuincy *sharedInstance = nil;
static dispatch_once_t onceToken;

dispatch_once(&onceToken, ^{
sharedInstance = [[KSCrashInstallationQuincy alloc] init];
});
return sharedInstance;
}

- (id) init
{
if((self = [super initWithRequiredProperties:[NSArray arrayWithObjects:
@"url",
nil]]))
{
}
return self;
return [super initWithRequiredProperties:[NSArray arrayWithObjects: @"url", nil]];
}

- (id<KSCrashReportFilter>) sink
Expand All @@ -114,10 +117,19 @@ - (id) init

@implementation KSCrashInstallationHockey

IMPLEMENT_EXCLUSIVE_SHARED_INSTANCE(KSCrashInstallationHockey)

@synthesize appIdentifier = _appIdentifier;

+ (instancetype) sharedInstance
{
static KSCrashInstallationHockey *sharedInstance = nil;
static dispatch_once_t onceToken;

dispatch_once(&onceToken, ^{
sharedInstance = [[KSCrashInstallationHockey alloc] init];
});
return sharedInstance;
}

- (id) init
{
if((self = [super initWithRequiredProperties:[NSArray arrayWithObjects:
Expand Down
2 changes: 1 addition & 1 deletion Source/KSCrash/Installations/KSCrashInstallationStandard.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@
/** The URL to connect to. */
@property(nonatomic,readwrite,retain) NSURL* url;

+ (KSCrashInstallationStandard*) sharedInstance;
+ (instancetype) sharedInstance;

@end
21 changes: 12 additions & 9 deletions Source/KSCrash/Installations/KSCrashInstallationStandard.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,27 @@

#import "KSCrashInstallationStandard.h"
#import "KSCrashInstallation+Private.h"
#import "KSSingleton.h"
#import "KSCrashReportSinkStandard.h"


@implementation KSCrashInstallationStandard

IMPLEMENT_EXCLUSIVE_SHARED_INSTANCE(KSCrashInstallationStandard)

@synthesize url = _url;

+ (instancetype) sharedInstance
{
static KSCrashInstallationStandard *sharedInstance = nil;
static dispatch_once_t onceToken;

dispatch_once(&onceToken, ^{
sharedInstance = [[KSCrashInstallationStandard alloc] init];
});
return sharedInstance;
}

- (id) init
{
if((self = [super initWithRequiredProperties:[NSArray arrayWithObjects:
@"url",
nil]]))
{
}
return self;
return [super initWithRequiredProperties:[NSArray arrayWithObjects: @"url", nil]];
}

- (id<KSCrashReportFilter>) sink
Expand Down
2 changes: 1 addition & 1 deletion Source/KSCrash/Installations/KSCrashInstallationVictory.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@
/** The user email of crash information *optional */
@property(nonatomic,readwrite,retain) NSString* userEmail;

+ (KSCrashInstallationVictory*) sharedInstance;
+ (instancetype) sharedInstance;

@end
21 changes: 12 additions & 9 deletions Source/KSCrash/Installations/KSCrashInstallationVictory.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,29 @@

#import "KSCrashInstallationVictory.h"
#import "KSCrashInstallation+Private.h"
#import "KSSingleton.h"
#import "KSCrashReportSinkVictory.h"


@implementation KSCrashInstallationVictory

IMPLEMENT_EXCLUSIVE_SHARED_INSTANCE(KSCrashInstallationVictory)

@synthesize url = _url;
@synthesize userName = _userName;
@synthesize userEmail = _userEmail;

+ (instancetype) sharedInstance
{
static KSCrashInstallationVictory *sharedInstance = nil;
static dispatch_once_t onceToken;

dispatch_once(&onceToken, ^{
sharedInstance = [[KSCrashInstallationVictory alloc] init];
});
return sharedInstance;
}

- (id) init
{
if((self = [super initWithRequiredProperties:[NSArray arrayWithObjects:
@"url",
nil]]))
{
}
return self;
return [super initWithRequiredProperties:[NSArray arrayWithObjects: @"url", nil]];
}

- (id<KSCrashReportFilter>) sink
Expand Down
12 changes: 10 additions & 2 deletions Source/KSCrash/Recording/KSCrash.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
#import "KSCrashReportStore.h"
#import "KSCrashState.h"
#import "KSJSONCodecObjC.h"
#import "KSSingleton.h"
#import "NSError+SimpleConstructor.h"

//#define KSLogger_LocalLevel TRACE
Expand Down Expand Up @@ -122,7 +121,16 @@ @implementation KSCrash
#pragma mark - Lifecycle -
// ============================================================================

IMPLEMENT_EXCLUSIVE_SHARED_INSTANCE(KSCrash)
+ (instancetype) sharedInstance
{
static KSCrash *sharedInstance = nil;
static dispatch_once_t onceToken;

dispatch_once(&onceToken, ^{
sharedInstance = [[KSCrash alloc] init];
});
return sharedInstance;
}

- (id) init
{
Expand Down
76 changes: 0 additions & 76 deletions Source/KSCrash/Recording/Tools/KSSingleton.h

This file was deleted.

Loading

0 comments on commit 81ccec2

Please sign in to comment.