Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add new feature, automatic switching mode between MRR and ARC #56

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 25 additions & 9 deletions OpenUDID.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,20 @@
distribution.
*/

#if __has_feature(objc_arc)
#error This file uses the classic non-ARC retain/release model; hints below...
// to selectively compile this file as non-ARC, do as follows:
// https://img.skitch.com/20120717-g3ag5h9a6ehkgpmpjiuen3qpwp.png
#if !__has_feature(objc_arc)
#define OpenUDIDAutorelease(__v) [__v autorelease];

#define OpenUDIDRetain(__v) [__v retain];
#define OpenUDIDReturnRetained OpenUDIDRetain

#define OpenUDIDRelease(__v) [__v release];
#else
#define OpenUDIDAutorelease(__v)

#define OpenUDIDRetain(__v)
#define OpenUDIDReturnRetained(__v) (__v)

#define OpenUDIDRelease(__v)
#endif

#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
Expand Down Expand Up @@ -230,9 +240,14 @@ + (NSString*) valueWithError:(NSError **)error {
{
// generate a new uuid and store it in user defaults
CFUUIDRef uuid = CFUUIDCreate(NULL);
appUID = (NSString *) CFUUIDCreateString(NULL, uuid);

#if !__has_feature(objc_arc)
appUID = [(NSString *)CFUUIDCreateString(NULL, uuid) autorelease];
#else
appUID = (NSString *)CFBridgingRelease(CFUUIDCreateString(NULL, uuid));
#endif

CFRelease(uuid);
[appUID autorelease];
}

NSString* openUDID = nil;
Expand Down Expand Up @@ -373,8 +388,8 @@ + (NSString*) valueWithError:(NSError **)error {
if (error!=nil) *error = [NSError errorWithDomain:kOpenUDIDDomain
code:kOpenUDIDErrorOptedOut
userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"Application with unique id %@ is opted-out from OpenUDID as of %@",appUID,optedOutDate],@"description", nil]];
kOpenUDIDSessionCache = [[NSString stringWithFormat:@"%040x",0] retain];
kOpenUDIDSessionCache = OpenUDIDReturnRetained(([NSString stringWithFormat:@"%040x", 0]));
return kOpenUDIDSessionCache;
}

Expand All @@ -390,7 +405,8 @@ + (NSString*) valueWithError:(NSError **)error {
code:kOpenUDIDErrorNone
userInfo:[NSDictionary dictionaryWithObjectsAndKeys:@"OpenUDID succesfully retrieved",@"description", nil]];
}
kOpenUDIDSessionCache = [openUDID retain];

kOpenUDIDSessionCache = OpenUDIDReturnRetained(openUDID);
return kOpenUDIDSessionCache;
}

Expand Down