Skip to content

Commit

Permalink
Merge pull request #13 from mattjgalloway/77cf5e765924a478ca4e90e88ba…
Browse files Browse the repository at this point in the history
…e988788f823e4

ARC-ify hpple
  • Loading branch information
topfunky committed May 15, 2012
2 parents ab1a51b + 77cf5e7 commit 798c471
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 34 deletions.
2 changes: 1 addition & 1 deletion Classes/HppleAppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
UIWindow *window;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, strong) IBOutlet UIWindow *window;

@end

5 changes: 0 additions & 5 deletions Classes/HppleAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ - (void)applicationDidFinishLaunching:(UIApplication *)application
}


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


@end
2 changes: 2 additions & 0 deletions Hpple.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion TFHpple.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@
- (NSArray *) searchWithXPathQuery:(NSString *)xPathOrCSS;
- (TFHppleElement *) peekAtSearchWithXPathQuery:(NSString *)xPathOrCSS;

@property (retain) NSData * data;
@property (nonatomic, strong, readonly) NSData * data;

@end
8 changes: 1 addition & 7 deletions TFHpple.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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 {
Expand Down
14 changes: 7 additions & 7 deletions TFHppleElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -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'.
Expand Down
11 changes: 2 additions & 9 deletions TFHppleElement.m
Original file line number Diff line number Diff line change
Expand Up @@ -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 -
Expand Down
8 changes: 4 additions & 4 deletions main.m
Original file line number Diff line number Diff line change
Expand Up @@ -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 798c471

Please sign in to comment.