Permalink
Browse files

ARC-ify

  • Loading branch information...
1 parent ab1a51b commit 77cf5e765924a478ca4e90e88bae988788f823e4 @mattjgalloway mattjgalloway committed May 13, 2012
Showing with 18 additions and 34 deletions.
  1. +1 −1 Classes/HppleAppDelegate.h
  2. +0 −5 Classes/HppleAppDelegate.m
  3. +2 −0 Hpple.xcodeproj/project.pbxproj
  4. +1 −1 TFHpple.h
  5. +1 −7 TFHpple.m
  6. +7 −7 TFHppleElement.h
  7. +2 −9 TFHppleElement.m
  8. +4 −4 main.m
@@ -13,7 +13,7 @@
UIWindow *window;
}
-@property (nonatomic, retain) IBOutlet UIWindow *window;
+@property (nonatomic, strong) IBOutlet UIWindow *window;
@end
@@ -23,11 +23,6 @@ - (void)applicationDidFinishLaunching:(UIApplication *)application
}
-- (void)dealloc
-{
- [window release];
- [super dealloc];
-}
@end
@@ -316,6 +316,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = YES;
+ CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
@@ -348,6 +349,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = YES;
+ CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES;
COPY_PHASE_STRIP = YES;
View
@@ -49,6 +49,6 @@
- (NSArray *) searchWithXPathQuery:(NSString *)xPathOrCSS;
- (TFHppleElement *) peekAtSearchWithXPathQuery:(NSString *)xPathOrCSS;
-@property (retain) NSData * data;
+@property (nonatomic, strong, readonly) NSData * data;
@end
View
@@ -34,19 +34,13 @@ @implementation TFHpple
@synthesize data;
-- (void) dealloc
-{
- [data release];
- [super dealloc];
-}
- (id) initWithData:(NSData *)theData isXML:(BOOL)isDataXML
{
if (!(self = [super init])) {
return nil;
}
- [theData retain];
data = theData;
isXML = isDataXML;
@@ -64,7 +58,7 @@ - (id) initWithHTMLData:(NSData *)theData
}
+ (TFHpple *) hppleWithData:(NSData *)theData isXML:(BOOL)isDataXML {
- return [[[[self class] alloc] initWithData:theData isXML:isDataXML] autorelease];
+ return [[[self class] alloc] initWithData:theData isXML:isDataXML];
}
+ (TFHpple *) hppleWithHTMLData:(NSData *)theData {
View
@@ -34,32 +34,32 @@
@private
NSDictionary * node;
- TFHppleElement *parent;
+ __unsafe_unretained TFHppleElement *parent;
}
- (id) initWithNode:(NSDictionary *) theNode;
+ (TFHppleElement *) hppleElementWithNode:(NSDictionary *) theNode;
// Returns this tag's innerHTML content.
-@property (nonatomic, readonly) NSString *content;
+@property (nonatomic, copy, readonly) NSString *content;
// Returns the name of the current tag, such as "h3".
-@property (nonatomic, readonly) NSString *tagName;
+@property (nonatomic, copy, readonly) NSString *tagName;
// Returns tag attributes with name as key and content as value.
// href = 'http://peepcode.com'
// class = 'highlight'
-@property (nonatomic, readonly) NSDictionary *attributes;
+@property (nonatomic, strong, readonly) NSDictionary *attributes;
// Returns the children of a given node
-@property (nonatomic, readonly) NSArray *children;
+@property (nonatomic, strong, readonly) NSArray *children;
// Returns the first child of a given node
-@property (nonatomic, readonly) TFHppleElement *firstChild;
+@property (nonatomic, strong, readonly) TFHppleElement *firstChild;
// the parent of a node
-@property (nonatomic, retain, readonly) TFHppleElement *parent;
+@property (nonatomic, unsafe_unretained, readonly) TFHppleElement *parent;
// Provides easy access to the content of a specific attribute,
// such as 'href' or 'class'.
View
@@ -37,32 +37,25 @@
static NSString * const TFHppleNodeAttributeNameKey = @"attributeName";
@interface TFHppleElement ()
-@property (nonatomic, retain, readwrite) TFHppleElement *parent;
+@property (nonatomic, unsafe_unretained, readwrite) TFHppleElement *parent;
@end
@implementation TFHppleElement
@synthesize parent;
-- (void) dealloc
-{
- [node release];
- [parent release];
- [super dealloc];
-}
- (id) initWithNode:(NSDictionary *) theNode
{
if (!(self = [super init]))
return nil;
- [theNode retain];
node = theNode;
return self;
}
+ (TFHppleElement *) hppleElementWithNode:(NSDictionary *) theNode {
- return [[[[self class] alloc] initWithNode:theNode] autorelease];
+ return [[[self class] alloc] initWithNode:theNode];
}
#pragma mark -
View
@@ -10,8 +10,8 @@
int main(int argc, char *argv[]) {
- NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
- int retVal = UIApplicationMain(argc, argv, nil, nil);
- [pool release];
- return retVal;
+ @autoreleasepool {
+ int retVal = UIApplicationMain(argc, argv, nil, nil);
+ return retVal;
+ }
}

0 comments on commit 77cf5e7

Please sign in to comment.