Skip to content

Commit

Permalink
Remove ...error:(NSError**)error methods - fixes SBJson#162
Browse files Browse the repository at this point in the history
  • Loading branch information
stig committed Jan 4, 2013
1 parent c82399b commit db3e39d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 66 deletions.
24 changes: 4 additions & 20 deletions src/main/objc/SBJsonParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,31 +71,15 @@
- (id)objectWithData:(NSData*)data;

/**
Return the object represented by the given string
Parse string and return the represented dictionary or array.
This method converts its input to an NSData object containing UTF8 and calls -objectWithData: with it.
Calls objectWithData: internally.
@return The NSArray or NSDictionary represented by the object, or nil if an error occured.
*/
- (id)objectWithString:(NSString *)repr;

/**
Return the object represented by the given string
This method calls objectWithString: internally. If an error occurs, and if error
is not nil, it creates an NSError object and returns this through its second argument.
@param jsonText the json string to parse
@param error pointer to an NSError object to populate on error
@param string An NSString containing JSON text.
@return The NSArray or NSDictionary represented by the object, or nil if an error occured.
@warning Deprecated in Version 3.2; will be removed in 4.0
*/

- (id)objectWithString:(NSString*)jsonText
error:(NSError**)error __attribute__ ((deprecated));
- (id)objectWithString:(NSString *)string;

@end

Expand Down
17 changes: 2 additions & 15 deletions src/main/objc/SBJsonParser.m
Original file line number Diff line number Diff line change
Expand Up @@ -84,21 +84,8 @@ - (id)objectWithData:(NSData *)data {
return nil;
}

- (id)objectWithString:(NSString *)repr {
return [self objectWithData:[repr dataUsingEncoding:NSUTF8StringEncoding]];
}

- (id)objectWithString:(NSString*)repr error:(NSError**)error_ {
id tmp = [self objectWithString:repr];
if (tmp)
return tmp;

if (error_) {
NSDictionary *ui = [NSDictionary dictionaryWithObjectsAndKeys:error, NSLocalizedDescriptionKey, nil];
*error_ = [NSError errorWithDomain:@"org.brautaset.SBJsonParser.ErrorDomain" code:0 userInfo:ui];
}

return nil;
- (id)objectWithString:(NSString *)string {
return [self objectWithData:[string dataUsingEncoding:NSUTF8StringEncoding]];
}

@end
20 changes: 2 additions & 18 deletions src/main/objc/SBJsonWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
@property (copy) NSComparator sortKeysComparator;

/**
Return JSON representation for the given object.
Generates string with JSON representation for the given object.
Returns a string containing JSON representation of the passed in value, or nil on error.
If nil is returned and error is not NULL, *error can be interrogated to find the cause of the error.
Expand All @@ -92,28 +92,12 @@
- (NSString*)stringWithObject:(id)value;

/**
Return JSON representation for the given object.
Generates JSON representation for the given object.
Returns an NSData object containing JSON represented as UTF8 text, or nil on error.
@param value any instance that can be represented as JSON text.
*/
- (NSData*)dataWithObject:(id)value;

/**
Return JSON representation (or fragment) for the given object.
Returns a string containing JSON representation of the passed in value, or nil on error.
If nil is returned and error is not NULL, *error can be interrogated to find the cause of the error.
@param value any instance that can be represented as a JSON fragment
@param error pointer to object to be populated with NSError on failure
@warning Deprecated in Version 3.2; will be removed in 4.0
*/
- (NSString*)stringWithObject:(id)value
error:(NSError**)error __attribute__ ((deprecated));


@end
13 changes: 0 additions & 13 deletions src/main/objc/SBJsonWriter.m
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,6 @@ - (NSString*)stringWithObject:(id)value {
if (data)
return [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
return nil;
}

- (NSString*)stringWithObject:(id)value error:(NSError**)error_ {
NSString *tmp = [self stringWithObject:value];
if (tmp)
return tmp;

if (error_) {
NSDictionary *ui = [NSDictionary dictionaryWithObjectsAndKeys:error, NSLocalizedDescriptionKey, nil];
*error_ = [NSError errorWithDomain:@"org.brautaset.SBJsonWriter.ErrorDomain" code:0 userInfo:ui];
}

return nil;
}

- (NSData*)dataWithObject:(id)object {
Expand Down

0 comments on commit db3e39d

Please sign in to comment.