Skip to content

Commit

Permalink
Adding bool plugin result
Browse files Browse the repository at this point in the history
  • Loading branch information
khawkins committed Jun 26, 2012
1 parent b0dfaf7 commit 9dbf619
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions CordovaLib/Classes/CDVPluginResult.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ typedef enum {
+(CDVPluginResult*) resultWithStatus: (CDVCommandStatus) statusOrdinal messageAsArray: (NSArray*) theMessage;
+(CDVPluginResult*) resultWithStatus: (CDVCommandStatus) statusOrdinal messageAsInt: (int) theMessage;
+(CDVPluginResult*) resultWithStatus: (CDVCommandStatus) statusOrdinal messageAsDouble: (double) theMessage;
+(CDVPluginResult*) resultWithStatus: (CDVCommandStatus) statusOrdinal messageAsBool: (BOOL) theMessage;
+(CDVPluginResult*) resultWithStatus: (CDVCommandStatus) statusOrdinal messageAsDictionary: (NSDictionary*) theMessage;
+(CDVPluginResult*) resultWithStatus: (CDVCommandStatus) statusOrdinal messageToErrorObject: (int) errorCode;

Expand Down
5 changes: 5 additions & 0 deletions CordovaLib/Classes/CDVPluginResult.m
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ +(CDVPluginResult*) resultWithStatus: (CDVCommandStatus) statusOrdinal messageAs
return [[[self alloc] initWithStatus: statusOrdinal message: [NSNumber numberWithDouble: theMessage]] autorelease];
}

+(CDVPluginResult*) resultWithStatus: (CDVCommandStatus) statusOrdinal messageAsBool: (BOOL) theMessage
{
return [[[self alloc] initWithStatus: statusOrdinal message: [NSNumber numberWithBool: theMessage]] autorelease];
}

+(CDVPluginResult*) resultWithStatus: (CDVCommandStatus) statusOrdinal messageAsDictionary: (NSDictionary*) theMessage
{
return [[[self alloc] initWithStatus: statusOrdinal message: theMessage] autorelease];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ - (void)testSerializingMessageAsDouble {
STAssertTrue([[NSNumber numberWithDouble:5.5] isEqual:message], nil);
}

- (void)testSerializingMessageAsBool {
CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:YES];
NSDictionary *dic = [[result toJSONString] objectFromJSONString];
NSNumber *message = [dic objectForKey:@"message"];
STAssertTrue([[NSNumber numberWithBool:YES] isEqual:message], nil);
}

- (void)testSerializingMessageAsArray {
NSArray *testValues = [NSArray arrayWithObjects:
[NSNull null],
Expand Down

0 comments on commit 9dbf619

Please sign in to comment.