From 033f09bbc728aa06b18fc6b81b81b9bcdbdf3c0c Mon Sep 17 00:00:00 2001 From: Travis CI Date: Sat, 13 Jun 2015 19:09:05 +0000 Subject: [PATCH] update website --- docs/nativemodulesios.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/nativemodulesios.html b/docs/nativemodulesios.html index f06f22b051e..b6f983486ea 100644 --- a/docs/nativemodulesios.html +++ b/docs/nativemodulesios.html @@ -20,7 +20,7 @@ CalendarManager.}

But by using the automatic type conversion feature, we can skip the manual conversion step completely, and just write:

RCT_EXPORT_METHOD(addEvent:(NSString *)name location:(NSString *)location date:(NSDate *)date) { // Date is ready to use! -}

You would then call this from JavaScript by using either:

CalendarManager.addEvent('Birthday Party', date.toTime()); // passing date as number of seconds since Unix epoch

or

CalendarManager.addEvent('Birthday Party', date.toISOString()); // passing date as ISO-8601 string

And both values would get converted correctly to the native NSDate. A bad value, like an Array, would generate a helpful "RedBox" error message.

As CalendarManager.addEvent method gets more and more complex, the number of arguments will grow. Some of them might be optional. In this case it's worth considering changing the API a little bit to accept a dictionary of event attributes, like this:

#import "RCTConvert.h" +}

You would then call this from JavaScript by using either:

CalendarManager.addEvent('Birthday Party', '4 Privet Drive, Surrey', date.toTime()); // passing date as number of seconds since Unix epoch

or

CalendarManager.addEvent('Birthday Party', '4 Privet Drive, Surrey', date.toISOString()); // passing date as ISO-8601 string

And both values would get converted correctly to the native NSDate. A bad value, like an Array, would generate a helpful "RedBox" error message.

As CalendarManager.addEvent method gets more and more complex, the number of arguments will grow. Some of them might be optional. In this case it's worth considering changing the API a little bit to accept a dictionary of event attributes, like this:

#import "RCTConvert.h" RCT_EXPORT_METHOD(addEvent:(NSString *)name details:(NSDictionary *)details) {