Skip to content

Commit 77cf5e7

Browse files
committed
ARC-ify
1 parent ab1a51b commit 77cf5e7

File tree

8 files changed

+18
-34
lines changed

8 files changed

+18
-34
lines changed

Classes/HppleAppDelegate.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
UIWindow *window;
1414
}
1515

16-
@property (nonatomic, retain) IBOutlet UIWindow *window;
16+
@property (nonatomic, strong) IBOutlet UIWindow *window;
1717

1818
@end
1919

Classes/HppleAppDelegate.m

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,6 @@ - (void)applicationDidFinishLaunching:(UIApplication *)application
2323
}
2424

2525

26-
- (void)dealloc
27-
{
28-
[window release];
29-
[super dealloc];
30-
}
3126

3227

3328
@end

Hpple.xcodeproj/project.pbxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@
316316
isa = XCBuildConfiguration;
317317
buildSettings = {
318318
ALWAYS_SEARCH_USER_PATHS = YES;
319+
CLANG_ENABLE_OBJC_ARC = YES;
319320
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
320321
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES;
321322
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
@@ -348,6 +349,7 @@
348349
isa = XCBuildConfiguration;
349350
buildSettings = {
350351
ALWAYS_SEARCH_USER_PATHS = YES;
352+
CLANG_ENABLE_OBJC_ARC = YES;
351353
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
352354
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES;
353355
COPY_PHASE_STRIP = YES;

TFHpple.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,6 @@
4949
- (NSArray *) searchWithXPathQuery:(NSString *)xPathOrCSS;
5050
- (TFHppleElement *) peekAtSearchWithXPathQuery:(NSString *)xPathOrCSS;
5151

52-
@property (retain) NSData * data;
52+
@property (nonatomic, strong, readonly) NSData * data;
5353

5454
@end

TFHpple.m

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,13 @@ @implementation TFHpple
3434

3535
@synthesize data;
3636

37-
- (void) dealloc
38-
{
39-
[data release];
40-
[super dealloc];
41-
}
4237

4338
- (id) initWithData:(NSData *)theData isXML:(BOOL)isDataXML
4439
{
4540
if (!(self = [super init])) {
4641
return nil;
4742
}
4843

49-
[theData retain];
5044
data = theData;
5145
isXML = isDataXML;
5246

@@ -64,7 +58,7 @@ - (id) initWithHTMLData:(NSData *)theData
6458
}
6559

6660
+ (TFHpple *) hppleWithData:(NSData *)theData isXML:(BOOL)isDataXML {
67-
return [[[[self class] alloc] initWithData:theData isXML:isDataXML] autorelease];
61+
return [[[self class] alloc] initWithData:theData isXML:isDataXML];
6862
}
6963

7064
+ (TFHpple *) hppleWithHTMLData:(NSData *)theData {

TFHppleElement.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,32 +34,32 @@
3434
@private
3535

3636
NSDictionary * node;
37-
TFHppleElement *parent;
37+
__unsafe_unretained TFHppleElement *parent;
3838
}
3939

4040
- (id) initWithNode:(NSDictionary *) theNode;
4141

4242
+ (TFHppleElement *) hppleElementWithNode:(NSDictionary *) theNode;
4343

4444
// Returns this tag's innerHTML content.
45-
@property (nonatomic, readonly) NSString *content;
45+
@property (nonatomic, copy, readonly) NSString *content;
4646

4747
// Returns the name of the current tag, such as "h3".
48-
@property (nonatomic, readonly) NSString *tagName;
48+
@property (nonatomic, copy, readonly) NSString *tagName;
4949

5050
// Returns tag attributes with name as key and content as value.
5151
// href = 'http://peepcode.com'
5252
// class = 'highlight'
53-
@property (nonatomic, readonly) NSDictionary *attributes;
53+
@property (nonatomic, strong, readonly) NSDictionary *attributes;
5454

5555
// Returns the children of a given node
56-
@property (nonatomic, readonly) NSArray *children;
56+
@property (nonatomic, strong, readonly) NSArray *children;
5757

5858
// Returns the first child of a given node
59-
@property (nonatomic, readonly) TFHppleElement *firstChild;
59+
@property (nonatomic, strong, readonly) TFHppleElement *firstChild;
6060

6161
// the parent of a node
62-
@property (nonatomic, retain, readonly) TFHppleElement *parent;
62+
@property (nonatomic, unsafe_unretained, readonly) TFHppleElement *parent;
6363

6464
// Provides easy access to the content of a specific attribute,
6565
// such as 'href' or 'class'.

TFHppleElement.m

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,32 +37,25 @@
3737
static NSString * const TFHppleNodeAttributeNameKey = @"attributeName";
3838

3939
@interface TFHppleElement ()
40-
@property (nonatomic, retain, readwrite) TFHppleElement *parent;
40+
@property (nonatomic, unsafe_unretained, readwrite) TFHppleElement *parent;
4141
@end
4242

4343
@implementation TFHppleElement
4444
@synthesize parent;
4545

46-
- (void) dealloc
47-
{
48-
[node release];
49-
[parent release];
50-
[super dealloc];
51-
}
5246

5347
- (id) initWithNode:(NSDictionary *) theNode
5448
{
5549
if (!(self = [super init]))
5650
return nil;
5751

58-
[theNode retain];
5952
node = theNode;
6053

6154
return self;
6255
}
6356

6457
+ (TFHppleElement *) hppleElementWithNode:(NSDictionary *) theNode {
65-
return [[[[self class] alloc] initWithNode:theNode] autorelease];
58+
return [[[self class] alloc] initWithNode:theNode];
6659
}
6760

6861
#pragma mark -

main.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

1111
int main(int argc, char *argv[]) {
1212

13-
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
14-
int retVal = UIApplicationMain(argc, argv, nil, nil);
15-
[pool release];
16-
return retVal;
13+
@autoreleasepool {
14+
int retVal = UIApplicationMain(argc, argv, nil, nil);
15+
return retVal;
16+
}
1717
}

0 commit comments

Comments
 (0)