Skip to content

Commit

Permalink
Remove the hacky dataToHere method in favour of just exposing the int…
Browse files Browse the repository at this point in the history
…ernal NSMutableData buffer
  • Loading branch information
stig committed Jan 30, 2011
1 parent e644523 commit a4ea6e7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
10 changes: 8 additions & 2 deletions Classes/SBJsonStreamWriter.h
Expand Up @@ -78,7 +78,14 @@
BOOL sortKeys, humanReadable;
}

- (NSData*)dataToHere;
/**
@brief The data written to the stream so far.
This is a mutable object. This means that you can write a chunk of its
contents to an NSOutputStream, then chop as many bytes as you wrote off
the beginning of the buffer.
*/
@property(readonly) NSMutableData *data;

@property(readonly) NSObject **states;
@property(readonly) NSUInteger depth;
Expand Down Expand Up @@ -152,6 +159,5 @@

@interface SBJsonStreamWriter (Private)
- (BOOL)writeValue:(id)v;
@property (readonly) NSMutableData*data;
@end

6 changes: 0 additions & 6 deletions Classes/SBJsonStreamWriter.m
Expand Up @@ -352,12 +352,6 @@ - (BOOL)writeNumber:(NSNumber*)number {
return YES;
}

- (NSData*)dataToHere {
NSData *ret = [data autorelease];
data = [[NSMutableData alloc] initWithCapacity:data.length];
return ret;
}

#pragma mark Private methods

- (NSUInteger)depth {
Expand Down
2 changes: 1 addition & 1 deletion Classes/SBJsonWriter.m
Expand Up @@ -91,7 +91,7 @@ - (NSData*)dataWithObject:(id)object {
}

if (ok)
return [streamWriter dataToHere];
return streamWriter.data;

self.error = streamWriter.error;
return nil;
Expand Down

0 comments on commit a4ea6e7

Please sign in to comment.