Skip to content
This repository was archived by the owner on Mar 21, 2024. It is now read-only.

Commit 02463ba

Browse files
committed
Automatic translation to ARC for SBJson + SBJsonTests
1 parent 037d3d1 commit 02463ba

15 files changed

+30
-66
lines changed

Classes/NSObject+SBJson.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3434
@implementation NSObject (NSObject_SBJsonWriting)
3535

3636
- (NSString *)JSONRepresentation {
37-
SBJsonWriter *writer = [[[SBJsonWriter alloc] init] autorelease];
37+
SBJsonWriter *writer = [[SBJsonWriter alloc] init];
3838
NSString *json = [writer stringWithObject:self];
3939
if (!json)
4040
NSLog(@"-JSONRepresentation failed. Error is: %@", writer.error);
@@ -48,7 +48,7 @@ - (NSString *)JSONRepresentation {
4848
@implementation NSString (NSString_SBJsonParsing)
4949

5050
- (id)JSONValue {
51-
SBJsonParser *parser = [[[SBJsonParser alloc] init] autorelease];
51+
SBJsonParser *parser = [[SBJsonParser alloc] init];
5252
id repr = [parser objectWithString:self];
5353
if (!repr)
5454
NSLog(@"-JSONValue failed. Error is: %@", parser.error);

Classes/SBJsonParser.m

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,6 @@ - (id)init {
4444
return self;
4545
}
4646

47-
- (void)dealloc {
48-
[error release];
49-
[super dealloc];
50-
}
5147

5248
#pragma mark Methods
5349

@@ -58,12 +54,12 @@ - (id)objectWithData:(NSData *)data {
5854
return nil;
5955
}
6056

61-
SBJsonStreamParserAccumulator *accumulator = [[[SBJsonStreamParserAccumulator alloc] init] autorelease];
57+
SBJsonStreamParserAccumulator *accumulator = [[SBJsonStreamParserAccumulator alloc] init];
6258

63-
SBJsonStreamParserAdapter *adapter = [[[SBJsonStreamParserAdapter alloc] init] autorelease];
59+
SBJsonStreamParserAdapter *adapter = [[SBJsonStreamParserAdapter alloc] init];
6460
adapter.delegate = accumulator;
6561

66-
SBJsonStreamParser *parser = [[[SBJsonStreamParser alloc] init] autorelease];
62+
SBJsonStreamParser *parser = [[SBJsonStreamParser alloc] init];
6763
parser.maxDepth = self.maxDepth;
6864
parser.delegate = adapter;
6965

Classes/SBJsonStreamParser.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ typedef enum {
102102
SBJsonTokeniser *tokeniser;
103103
}
104104

105-
@property (nonatomic, assign) SBJsonStreamParserState *state; // Private
106-
@property (nonatomic, readonly, retain) NSMutableArray *stateStack; // Private
105+
@property (nonatomic, unsafe_unretained) SBJsonStreamParserState *state; // Private
106+
@property (nonatomic, readonly, strong) NSMutableArray *stateStack; // Private
107107

108108
/**
109109
@brief Expect multiple documents separated by whitespace
@@ -129,7 +129,7 @@ typedef enum {
129129
Usually this should be an instance of SBJsonStreamParserAdapter, but you can
130130
substitute your own implementation of the SBJsonStreamParserDelegate protocol if you need to.
131131
*/
132-
@property (assign) id<SBJsonStreamParserDelegate> delegate;
132+
@property (unsafe_unretained) id<SBJsonStreamParserDelegate> delegate;
133133

134134
/**
135135
@brief The max parse depth

Classes/SBJsonStreamParser.m

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,7 @@ - (id)init {
5858
}
5959

6060
- (void)dealloc {
61-
self.error = nil;
6261
self.state = nil;
63-
[stateStack release];
64-
[tokeniser release];
65-
[super dealloc];
6662
}
6763

6864
#pragma mark Methods

Classes/SBJsonStreamParserAccumulator.m

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,15 @@ @implementation SBJsonStreamParserAccumulator
3333

3434
@synthesize value;
3535

36-
- (void)dealloc {
37-
[value release];
38-
[super dealloc];
39-
}
4036

4137
#pragma mark SBJsonStreamParserAdapterDelegate
4238

4339
- (void)parser:(SBJsonStreamParser*)parser foundArray:(NSArray *)array {
44-
value = [array retain];
40+
value = array;
4541
}
4642

4743
- (void)parser:(SBJsonStreamParser*)parser foundObject:(NSDictionary *)dict {
48-
value = [dict retain];
44+
value = dict;
4945
}
5046

5147
@end

Classes/SBJsonStreamParserAdapter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,6 @@ typedef enum {
143143
@brief Your delegate object
144144
Set this to the object you want to receive the SBJsonStreamParserAdapterDelegate messages.
145145
*/
146-
@property (assign) id<SBJsonStreamParserAdapterDelegate> delegate;
146+
@property (unsafe_unretained) id<SBJsonStreamParserAdapterDelegate> delegate;
147147

148148
@end

Classes/SBJsonStreamParserAdapter.m

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,6 @@ - (id)init {
5959
return self;
6060
}
6161

62-
- (void)dealloc {
63-
[keyStack release];
64-
[stack release];
65-
[super dealloc];
66-
}
6762

6863
#pragma mark Private methods
6964

@@ -116,7 +111,7 @@ - (void)parser:(SBJsonStreamParser*)parser found:(id)obj {
116111

117112
- (void)parserFoundObjectStart:(SBJsonStreamParser*)parser {
118113
if (++depth > self.levelsToSkip) {
119-
dict = [[NSMutableDictionary new] autorelease];
114+
dict = [NSMutableDictionary new];
120115
[stack addObject:dict];
121116
currentType = SBJsonStreamParserAdapterObject;
122117
}
@@ -128,27 +123,25 @@ - (void)parser:(SBJsonStreamParser*)parser foundObjectKey:(NSString*)key_ {
128123

129124
- (void)parserFoundObjectEnd:(SBJsonStreamParser*)parser {
130125
if (depth-- > self.levelsToSkip) {
131-
id value = [dict retain];
126+
id value = dict;
132127
[self pop];
133128
[self parser:parser found:value];
134-
[value release];
135129
}
136130
}
137131

138132
- (void)parserFoundArrayStart:(SBJsonStreamParser*)parser {
139133
if (++depth > self.levelsToSkip) {
140-
array = [[NSMutableArray new] autorelease];
134+
array = [NSMutableArray new];
141135
[stack addObject:array];
142136
currentType = SBJsonStreamParserAdapterArray;
143137
}
144138
}
145139

146140
- (void)parserFoundArrayEnd:(SBJsonStreamParser*)parser {
147141
if (depth-- > self.levelsToSkip) {
148-
id value = [array retain];
142+
id value = array;
149143
[self pop];
150144
[self parser:parser found:value];
151-
[value release];
152145
}
153146
}
154147

Classes/SBJsonStreamWriter.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,14 @@
8686
NSMutableDictionary *cache;
8787
}
8888

89-
@property (nonatomic, assign) SBJsonStreamWriterState *state; // Internal
90-
@property (nonatomic, readonly, retain) NSMutableArray *stateStack; // Internal
89+
@property (nonatomic, unsafe_unretained) SBJsonStreamWriterState *state; // Internal
90+
@property (nonatomic, readonly, strong) NSMutableArray *stateStack; // Internal
9191

9292
/**
9393
@brief delegate to receive JSON output
9494
Delegate that will receive messages with output.
9595
*/
96-
@property (assign) id<SBJsonStreamWriterDelegate> delegate;
96+
@property (unsafe_unretained) id<SBJsonStreamWriterDelegate> delegate;
9797

9898
/**
9999
@brief The maximum recursing depth.

Classes/SBJsonStreamWriter.m

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,7 @@ - (id)init {
7373
}
7474

7575
- (void)dealloc {
76-
self.error = nil;
7776
self.state = nil;
78-
[stateStack release];
79-
[cache release];
80-
[super dealloc];
8177
}
8278

8379
#pragma mark Methods

Classes/SBJsonStreamWriterAccumulator.m

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,6 @@ - (id)init {
4242
return self;
4343
}
4444

45-
- (void)dealloc {
46-
[data release];
47-
[super dealloc];
48-
}
4945

5046
#pragma mark SBJsonStreamWriterDelegate
5147

0 commit comments

Comments
 (0)