Skip to content

Commit cfa1c91

Browse files
committed
Cleaned whitespace
1 parent 6752758 commit cfa1c91

File tree

1 file changed

+50
-50
lines changed

1 file changed

+50
-50
lines changed

FCUUID/FCUUID.m

+50-50
Original file line numberDiff line numberDiff line change
@@ -25,58 +25,58 @@ +(FCUUID *)sharedInstance
2525
{
2626
static FCUUID *instance = nil;
2727
static dispatch_once_t token;
28-
28+
2929
dispatch_once(&token, ^{
3030
instance = [[self alloc] init];
3131
});
32-
32+
3333
return instance;
3434
}
3535

3636

3737
-(instancetype)init
3838
{
3939
self = [super init];
40-
40+
4141
if(self)
4242
{
4343
[self uuidsOfUserDevices_iCloudInit];
4444
}
45-
45+
4646
return self;
4747
}
4848

4949

5050
-(NSString *)_getOrCreateValueForKey:(NSString *)key defaultValue:(NSString *)defaultValue userDefaults:(BOOL)userDefaults keychain:(BOOL)keychain service:(NSString *)service accessGroup:(NSString *)accessGroup synchronizable:(BOOL)synchronizable
5151
{
5252
NSString *value = [self _getValueForKey:key userDefaults:userDefaults keychain:keychain service:service accessGroup:accessGroup];
53-
53+
5454
if(!value){
5555
value = defaultValue;
5656
}
57-
57+
5858
if(!value){
5959
value = [self uuid];
6060
}
61-
61+
6262
[self _setValue:value forKey:key userDefaults:userDefaults keychain:keychain service:service accessGroup:accessGroup synchronizable:synchronizable];
63-
63+
6464
return value;
6565
}
6666

6767

6868
-(NSString *)_getValueForKey:(NSString *)key userDefaults:(BOOL)userDefaults keychain:(BOOL)keychain service:(NSString *)service accessGroup:(NSString *)accessGroup
6969
{
7070
NSString *value = nil;
71-
71+
7272
if(!value && keychain ){
7373
value = [UICKeyChainStore stringForKey:key service:service accessGroup:accessGroup];
7474
}
75-
75+
7676
if(!value && userDefaults ){
7777
value = [[NSUserDefaults standardUserDefaults] stringForKey:key];
7878
}
79-
79+
8080
return value;
8181
}
8282

@@ -87,7 +87,7 @@ -(void)_setValue:(NSString *)value forKey:(NSString *)key userDefaults:(BOOL)use
8787
[[NSUserDefaults standardUserDefaults] setObject:value forKey:key];
8888
[[NSUserDefaults standardUserDefaults] synchronize];
8989
}
90-
90+
9191
if( value && keychain ){
9292
UICKeyChainStore *keychain = [UICKeyChainStore keyChainStoreWithService:service accessGroup:accessGroup];
9393
[keychain setSynchronizable:synchronizable];
@@ -99,11 +99,11 @@ -(void)_setValue:(NSString *)value forKey:(NSString *)key userDefaults:(BOOL)use
9999
-(NSString *)uuid
100100
{
101101
//also known as uuid/universallyUniqueIdentifier
102-
102+
103103
CFUUIDRef uuidRef = CFUUIDCreate(NULL);
104104
CFStringRef uuidStringRef = CFUUIDCreateString(NULL, uuidRef);
105105
CFRelease(uuidRef);
106-
106+
107107
NSString *uuidValue = (__bridge_transfer NSString *)uuidStringRef;
108108
uuidValue = [uuidValue lowercaseString];
109109
uuidValue = [uuidValue stringByReplacingOccurrencesOfString:@"-" withString:@""];
@@ -116,15 +116,15 @@ -(NSString *)uuidForKey:(id<NSCopying>)key
116116
if( _uuidForKey == nil ){
117117
_uuidForKey = [[NSMutableDictionary alloc] init];
118118
}
119-
119+
120120
NSString *uuidValue = [_uuidForKey objectForKey:key];
121-
121+
122122
if( uuidValue == nil ){
123123
uuidValue = [self uuid];
124-
124+
125125
[_uuidForKey setObject:uuidValue forKey:key];
126126
}
127-
127+
128128
return uuidValue;
129129
}
130130

@@ -134,7 +134,7 @@ -(NSString *)uuidForSession
134134
if( _uuidForSession == nil ){
135135
_uuidForSession = [self uuid];
136136
}
137-
137+
138138
return _uuidForSession;
139139
}
140140

@@ -144,7 +144,7 @@ -(NSString *)uuidForInstallation
144144
if( _uuidForInstallation == nil ){
145145
_uuidForInstallation = [self _getOrCreateValueForKey:_uuidForInstallationKey defaultValue:nil userDefaults:YES keychain:NO service:nil accessGroup:nil synchronizable:NO];
146146
}
147-
147+
148148
return _uuidForInstallation;
149149
}
150150

@@ -154,7 +154,7 @@ -(NSString *)uuidForVendor
154154
if( _uuidForVendor == nil ){
155155
_uuidForVendor = [[[[[UIDevice currentDevice] identifierForVendor] UUIDString] lowercaseString] stringByReplacingOccurrencesOfString:@"-" withString:@""];
156156
}
157-
157+
158158
return _uuidForVendor;
159159
}
160160

@@ -169,11 +169,11 @@ -(void)uuidForDevice_updateWithValue:(NSString *)value
169169
-(NSString *)uuidForDevice
170170
{
171171
//also known as udid/uniqueDeviceIdentifier but this doesn't persists to system reset
172-
172+
173173
if( _uuidForDevice == nil ){
174174
_uuidForDevice = [self _getOrCreateValueForKey:_uuidForDeviceKey defaultValue:nil userDefaults:YES keychain:YES service:nil accessGroup:nil synchronizable:NO];
175175
}
176-
176+
177177
return _uuidForDevice;
178178
}
179179

@@ -184,23 +184,23 @@ -(NSString *)uuidForDeviceMigratingValue:(NSString *)value commitMigration:(BOOL
184184
{
185185
NSString *oldValue = [self uuidForDevice];
186186
NSString *newValue = [NSString stringWithString:value];
187-
187+
188188
if([oldValue isEqualToString:newValue])
189189
{
190190
return oldValue;
191191
}
192-
192+
193193
if(commitMigration)
194194
{
195195
[self uuidForDevice_updateWithValue:newValue];
196-
196+
197197
NSMutableOrderedSet *uuidsOfUserDevicesSet = [[NSMutableOrderedSet alloc] initWithArray:[self uuidsOfUserDevices]];
198198
[uuidsOfUserDevicesSet addObject:newValue];
199199
[uuidsOfUserDevicesSet removeObject:oldValue];
200-
200+
201201
[self uuidsOfUserDevices_updateWithValue:[uuidsOfUserDevicesSet array]];
202202
[self uuidsOfUserDevices_iCloudSync];
203-
203+
204204
return [self uuidForDevice];
205205
}
206206
else {
@@ -209,7 +209,7 @@ -(NSString *)uuidForDeviceMigratingValue:(NSString *)value commitMigration:(BOOL
209209
}
210210
else {
211211
[NSException raise:@"Invalid uuid to migrate" format:@"uuid value should be a string of 32 or 36 characters."];
212-
212+
213213
return nil;
214214
}
215215
}
@@ -230,25 +230,25 @@ -(NSString *)uuidForDeviceMigratingValueForKey:(NSString *)key service:(NSString
230230
-(NSString *)uuidForDeviceMigratingValueForKey:(NSString *)key service:(NSString *)service accessGroup:(NSString *)accessGroup commitMigration:(BOOL)commitMigration
231231
{
232232
NSString *uuidToMigrate = [self _getValueForKey:key userDefaults:YES keychain:YES service:service accessGroup:accessGroup];
233-
233+
234234
return [self uuidForDeviceMigratingValue:uuidToMigrate commitMigration:commitMigration];
235235
}
236236

237237

238238
-(void)uuidsOfUserDevices_iCloudInit
239239
{
240240
_uuidsOfUserDevices_iCloudAvailable = NO;
241-
241+
242242
if(NSClassFromString(@"NSUbiquitousKeyValueStore"))
243243
{
244244
NSUbiquitousKeyValueStore *iCloud = [NSUbiquitousKeyValueStore defaultStore];
245-
245+
246246
if(iCloud)
247247
{
248248
_uuidsOfUserDevices_iCloudAvailable = YES;
249-
249+
250250
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(uuidsOfUserDevices_iCloudChange:) name:NSUbiquitousKeyValueStoreDidChangeExternallyNotification object:nil];
251-
251+
252252
[self uuidsOfUserDevices_iCloudSync];
253253
}
254254
else {
@@ -266,17 +266,17 @@ -(void)uuidsOfUserDevices_iCloudSync
266266
if( _uuidsOfUserDevices_iCloudAvailable )
267267
{
268268
NSUbiquitousKeyValueStore *iCloud = [NSUbiquitousKeyValueStore defaultStore];
269-
269+
270270
//if keychain contains more device identifiers than icloud, maybe that icloud has been empty, so re-write these identifiers to iCloud
271271
for ( NSString *uuidOfUserDevice in [self uuidsOfUserDevices] )
272272
{
273273
NSString *uuidOfUserDeviceAsKey = [NSString stringWithFormat:@"%@_%@", _uuidForDeviceKey, uuidOfUserDevice];
274-
274+
275275
if(![[iCloud stringForKey:uuidOfUserDeviceAsKey] isEqualToString:uuidOfUserDevice]){
276276
[iCloud setString:uuidOfUserDevice forKey:uuidOfUserDeviceAsKey];
277277
}
278278
}
279-
279+
280280
//toggle a boolean value to force notification on other devices, useful for debug
281281
[iCloud setBool:![iCloud boolForKey:_uuidsOfUserDevicesToggleKey] forKey:_uuidsOfUserDevicesToggleKey];
282282
[iCloud synchronize];
@@ -290,26 +290,26 @@ -(void)uuidsOfUserDevices_iCloudChange:(NSNotification *)notification
290290
{
291291
NSMutableOrderedSet *uuidsSet = [[NSMutableOrderedSet alloc] initWithArray:[self uuidsOfUserDevices]];
292292
NSInteger uuidsCount = [uuidsSet count];
293-
293+
294294
NSUbiquitousKeyValueStore *iCloud = [NSUbiquitousKeyValueStore defaultStore];
295295
NSDictionary *iCloudDict = [iCloud dictionaryRepresentation];
296-
296+
297297
//NSLog(@"uuidsOfUserDevicesSync: %@", iCloudDict);
298-
298+
299299
[iCloudDict enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
300-
300+
301301
NSString *uuidKey = (NSString *)key;
302-
302+
303303
if([uuidKey rangeOfString:_uuidForDeviceKey].location == 0)
304304
{
305305
if([obj isKindOfClass:[NSString class]])
306306
{
307307
NSString *uuidValue = (NSString *)obj;
308-
308+
309309
if([uuidKey rangeOfString:uuidValue].location != NSNotFound && [self uuidValueIsValid:uuidValue])
310310
{
311311
//NSLog(@"uuid: %@", uuidValue);
312-
312+
313313
[uuidsSet addObject:uuidValue];
314314
}
315315
else {
@@ -318,11 +318,11 @@ -(void)uuidsOfUserDevices_iCloudChange:(NSNotification *)notification
318318
}
319319
}
320320
}];
321-
321+
322322
if([uuidsSet count] > uuidsCount)
323323
{
324324
[self uuidsOfUserDevices_updateWithValue:[uuidsSet array]];
325-
325+
326326
NSDictionary *userInfo = [NSDictionary dictionaryWithObject:[self uuidsOfUserDevices] forKey:@"uuidsOfUserDevices"];
327327
[[NSNotificationCenter defaultCenter] postNotificationName:FCUUIDsOfUserDevicesDidChangeNotification object:self userInfo:userInfo];
328328
}
@@ -342,7 +342,7 @@ -(NSArray *)uuidsOfUserDevices
342342
if( _uuidsOfUserDevices == nil ){
343343
_uuidsOfUserDevices = [self _getOrCreateValueForKey:_uuidsOfUserDevicesKey defaultValue:[self uuidForDevice] userDefaults:YES keychain:YES service:nil accessGroup:nil synchronizable:YES];
344344
}
345-
345+
346346
return [_uuidsOfUserDevices componentsSeparatedByString:@"|"];
347347
}
348348

@@ -361,15 +361,15 @@ -(BOOL)uuidValueIsValid:(NSString *)uuidValue
361361
{
362362
NSString *uuidPattern = @"^[0-9a-f]{32}|[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}$";
363363
NSRegularExpression *uuidRegExp = [NSRegularExpression regularExpressionWithPattern:uuidPattern options:NSRegularExpressionCaseInsensitive error:nil];
364-
364+
365365
NSRange uuidValueRange = NSMakeRange(0, [uuidValue length]);
366366
NSRange uuidMatchRange = [uuidRegExp rangeOfFirstMatchInString:uuidValue options:0 range:uuidValueRange];
367367
NSString *uuidMatchValue;
368-
368+
369369
if(!NSEqualRanges(uuidMatchRange, NSMakeRange(NSNotFound, 0)))
370370
{
371371
uuidMatchValue = [uuidValue substringWithRange:uuidMatchRange];
372-
372+
373373
if([uuidMatchValue isEqualToString:uuidValue])
374374
{
375375
return YES;

0 commit comments

Comments
 (0)