Skip to content

Commit

Permalink
Migrate to ARC.
Browse files Browse the repository at this point in the history
  • Loading branch information
dave-perry committed Apr 10, 2014
1 parent 64a593e commit fe9b30c
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 36 deletions.
4 changes: 2 additions & 2 deletions Additions/NSError-KIFAdditions.m
Expand Up @@ -18,7 +18,7 @@ + (instancetype)KIFErrorWithFormat:(NSString *)format, ...
{
va_list args;
va_start(args, format);
NSString *description = [[[NSString alloc] initWithFormat:format arguments:args] autorelease];
NSString *description = [[NSString alloc] initWithFormat:format arguments:args];
va_end(args);

return [self errorWithDomain:@"KIFTest" code:KIFTestStepResultFailure userInfo:@{NSLocalizedDescriptionKey: description}];
Expand All @@ -28,7 +28,7 @@ + (instancetype)KIFErrorWithUnderlyingError:(NSError *)underlyingError format:(N
{
va_list args;
va_start(args, format);
NSString *description = [[[NSString alloc] initWithFormat:format arguments:args] autorelease];
NSString *description = [[NSString alloc] initWithFormat:format arguments:args];
va_end(args);

return [self errorWithDomain:@"KIFTest" code:KIFTestStepResultFailure userInfo:@{NSLocalizedDescriptionKey: description, NSUnderlyingErrorKey: underlyingError}];
Expand Down
4 changes: 2 additions & 2 deletions Additions/UIApplication-KIFAdditions.m
Expand Up @@ -105,7 +105,7 @@ - (NSArray *)windowsWithKeyWindow
if (![windows containsObject:keyWindow]) {
[windows addObject:keyWindow];
}
return [windows autorelease];
return windows;
}

#pragma mark - Screenshoting
Expand Down Expand Up @@ -168,7 +168,7 @@ - (NSMutableArray *)KIF_runLoopModes;

- (CFStringRef)currentRunLoopMode;
{
return (CFStringRef)[self KIF_runLoopModes].lastObject;
return (__bridge CFStringRef)[self KIF_runLoopModes].lastObject;
}

- (void)KIF_pushRunLoopMode:(NSString *)mode;
Expand Down
16 changes: 4 additions & 12 deletions Additions/UIView-KIFAdditions.m
Expand Up @@ -160,7 +160,7 @@ - (UIAccessibilityElement *)accessibilityElementMatchingBlock:(BOOL(^)(UIAccessi
NSMutableArray *elementStack = [NSMutableArray arrayWithObject:self];

while (elementStack.count) {
UIAccessibilityElement *element = [[[elementStack lastObject] retain] autorelease];
UIAccessibilityElement *element = [elementStack lastObject];
[elementStack removeLastObject];

BOOL elementMatches = matchBlock(element);
Expand Down Expand Up @@ -275,15 +275,14 @@ - (BOOL)isDescendantOfFirstResponder;

- (void)flash;
{
UIColor *originalBackgroundColor = [self.backgroundColor retain];
UIColor *originalBackgroundColor = self.backgroundColor;
for (NSUInteger i = 0; i < 5; i++) {
self.backgroundColor = [UIColor yellowColor];
CFRunLoopRunInMode(kCFRunLoopDefaultMode, .05, false);
self.backgroundColor = [UIColor blueColor];
CFRunLoopRunInMode(kCFRunLoopDefaultMode, .05, false);
}
self.backgroundColor = originalBackgroundColor;
[originalBackgroundColor release];
}

- (void)tap;
Expand All @@ -303,9 +302,8 @@ - (void)tapAtPoint:(CGPoint)point;
if ([NSStringFromClass([self class]) isEqual:@"UIWebBrowserView"]) {
webBrowserView = self;
} else if ([self isKindOfClass:[UIWebView class]]) {
id webViewInternal = nil;
object_getInstanceVariable(self, "_internal", (void **)&webViewInternal);
object_getInstanceVariable(webViewInternal, "browserView", (void **)&webBrowserView);
id webViewInternal = [self valueForKey:@"_internal"];
webBrowserView = [webViewInternal valueForKey:@"browserView"];
}

if (webBrowserView) {
Expand All @@ -329,7 +327,6 @@ - (void)tapAtPoint:(CGPoint)point;
[self becomeFirstResponder];
}

[touch release];
}

#define DRAG_TOUCH_DELAY 0.01
Expand Down Expand Up @@ -363,7 +360,6 @@ - (void)longPressAtPoint:(CGPoint)point duration:(NSTimeInterval)duration
[self becomeFirstResponder];
}

[touch release];
}

- (void)dragFromPoint:(CGPoint)startPoint toPoint:(CGPoint)endPoint;
Expand Down Expand Up @@ -431,7 +427,6 @@ - (void)dragAlongPathWithPoints:(CGPoint *)points count:(NSInteger)count;
while (UIApplicationCurrentRunMode != kCFRunLoopDefaultMode) {
CFRunLoopRunInMode(UIApplicationCurrentRunMode, 0.1, false);
}
[touch release];
}

- (BOOL)isProbablyTappable
Expand Down Expand Up @@ -536,13 +531,10 @@ - (UIEvent *)_eventWithTouch:(UITouch *)touch;
eventProxy->flags = ([touch phase] == UITouchPhaseEnded) ? 0x1010180 : 0x3010180;
eventProxy->type = 3001;

NSSet *allTouches = [event allTouches];
[event _clearTouches];
[allTouches makeObjectsPerformSelector:@selector(autorelease)];
[event _setGSEvent:(struct __GSEvent *)eventProxy];
[event _addTouch:touch forDelayedDelivery:NO];

[eventProxy release];
return event;
}

Expand Down
5 changes: 2 additions & 3 deletions Classes/KIFSystemTestActor.m
Expand Up @@ -28,8 +28,7 @@ - (NSNotification *)waitForNotificationName:(NSString *)name object:(id)object w
{
__block NSNotification *detectedNotification = nil;
id observer = [[NSNotificationCenter defaultCenter] addObserverForName:name object:object queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *note) {
[detectedNotification release];
detectedNotification = [note retain];
detectedNotification = note;
}];

if (block) {
Expand All @@ -47,7 +46,7 @@ - (NSNotification *)waitForNotificationName:(NSString *)name object:(id)object w
}
}];

return [detectedNotification autorelease];
return detectedNotification;
}

- (void)simulateMemoryWarning
Expand Down
4 changes: 2 additions & 2 deletions Classes/KIFTestActor.h
Expand Up @@ -86,9 +86,9 @@ typedef void (^KIFTestCompletionBlock)(KIFTestStepResult result, NSError *error)

+ (instancetype)actorInFile:(NSString *)file atLine:(NSInteger)line delegate:(id<KIFTestActorDelegate>)delegate;

@property (nonatomic, readonly) NSString *file;
@property (strong, nonatomic, readonly) NSString *file;
@property (nonatomic, readonly) NSInteger line;
@property (nonatomic, readonly) id<KIFTestActorDelegate> delegate;
@property (weak, nonatomic, readonly) id<KIFTestActorDelegate> delegate;
@property (nonatomic) NSTimeInterval executionBlockTimeout;

- (instancetype)usingTimeout:(NSTimeInterval)executionBlockTimeout;
Expand Down
9 changes: 2 additions & 7 deletions Classes/KIFTestActor.m
Expand Up @@ -72,7 +72,7 @@ - (instancetype)initWithFile:(NSString *)file line:(NSInteger)line delegate:(id<
{
self = [super init];
if (self) {
_file = [file retain];
_file = file;
_line = line;
_delegate = delegate;
_executionBlockTimeout = [[self class] defaultTimeout];
Expand All @@ -82,7 +82,7 @@ - (instancetype)initWithFile:(NSString *)file line:(NSInteger)line delegate:(id<

+ (instancetype)actorInFile:(NSString *)file atLine:(NSInteger)line delegate:(id<KIFTestActorDelegate>)delegate
{
return [[[self alloc] initWithFile:file line:line delegate:delegate] autorelease];
return [[self alloc] initWithFile:file line:line delegate:delegate];
}

- (instancetype)usingTimeout:(NSTimeInterval)executionBlockTimeout
Expand Down Expand Up @@ -130,11 +130,6 @@ - (void)runBlock:(KIFTestExecutionBlock)executionBlock
[self runBlock:executionBlock complete:nil];
}

- (void)dealloc
{
[_file release];
[super dealloc];
}

#pragma mark Class Methods

Expand Down
2 changes: 1 addition & 1 deletion Classes/KIFTestCase.m
Expand Up @@ -129,7 +129,7 @@ - (void)failWithException:(NSException *)exception stopTest:(BOOL)stop
NSLog(@"Fatal failure encountered: %@", exception.description);
NSLog(@"Stopping tests since stopTestsOnFirstBigFailure = YES");

KIFTestActor *waiter = [[[KIFTestActor alloc] init] autorelease];
KIFTestActor *waiter = [[KIFTestActor alloc] init];
[waiter waitForTimeInterval:[[NSDate distantFuture] timeIntervalSinceNow]];

return;
Expand Down
2 changes: 1 addition & 1 deletion Classes/KIFTestStepValidation.h
Expand Up @@ -51,7 +51,7 @@

@interface _MockKIFTestActorDelegate : NSObject<KIFTestActorDelegate>
@property (nonatomic, assign) BOOL failed;
@property (nonatomic, retain) NSArray *exceptions;
@property (nonatomic, strong) NSArray *exceptions;
@property (nonatomic, assign) BOOL stopped;

+ (instancetype)mockDelegate;
Expand Down
7 changes: 1 addition & 6 deletions Classes/KIFTestStepValidation.m
Expand Up @@ -27,13 +27,8 @@ - (void)failWithExceptions:(NSArray *)exceptions stopTest:(BOOL)stop

+ (instancetype)mockDelegate
{
return [[[self alloc] init] autorelease];
return [[self alloc] init];
}

- (void)dealloc
{
[_exceptions release];
[super dealloc];
}

@end
9 changes: 9 additions & 0 deletions KIF.xcodeproj/project.pbxproj
Expand Up @@ -971,6 +971,7 @@
AAB07270139719AC008AF393 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_OBJC_ARC = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREFIX_HEADER = "Classes/KIF-Prefix.pch";
Expand All @@ -992,6 +993,7 @@
AAB07271139719AC008AF393 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_OBJC_ARC = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_PREFIX_HEADER = "Classes/KIF-Prefix.pch";
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
Expand All @@ -1010,6 +1012,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ENABLE_OBJC_ARC = YES;
DSTROOT = /tmp/KIF.dst;
FRAMEWORK_SEARCH_PATHS = (
"\"$(SDKROOT)/Developer/Library/Frameworks\"",
Expand All @@ -1029,6 +1032,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ENABLE_OBJC_ARC = YES;
DSTROOT = /tmp/KIF.dst;
FRAMEWORK_SEARCH_PATHS = (
"\"$(SDKROOT)/Developer/Library/Frameworks\"",
Expand All @@ -1048,6 +1052,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ENABLE_OBJC_ARC = YES;
DSTROOT = /tmp/KIF.dst;
FRAMEWORK_SEARCH_PATHS = (
"\"$(SDKROOT)/Developer/Library/Frameworks\"",
Expand Down Expand Up @@ -1286,6 +1291,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ENABLE_OBJC_ARC = YES;
DSTROOT = /tmp/KIF.dst;
FRAMEWORK_SEARCH_PATHS = "\"$(SDKROOT)/Developer/Library/Frameworks\"";
GCC_PREFIX_HEADER = "Classes/KIF-Prefix.pch";
Expand All @@ -1302,6 +1308,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ENABLE_OBJC_ARC = YES;
DSTROOT = /tmp/KIF.dst;
FRAMEWORK_SEARCH_PATHS = "\"$(SDKROOT)/Developer/Library/Frameworks\"";
GCC_PREFIX_HEADER = "Classes/KIF-Prefix.pch";
Expand All @@ -1313,6 +1320,7 @@
EBAE48FF17A5B1380005EE19 /* Coverage */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_OBJC_ARC = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_GENERATE_TEST_COVERAGE_FILES = YES;
GCC_INSTRUMENT_PROGRAM_FLOW_ARCS = YES;
Expand All @@ -1336,6 +1344,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ENABLE_OBJC_ARC = YES;
DSTROOT = /tmp/KIF.dst;
FRAMEWORK_SEARCH_PATHS = "\"$(SDKROOT)/Developer/Library/Frameworks\"";
GCC_PREFIX_HEADER = "Classes/KIF-Prefix.pch";
Expand Down

0 comments on commit fe9b30c

Please sign in to comment.