File tree 2 files changed +33
-0
lines changed
iphone/TitaniumKit/TitaniumKit/Sources/API
2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -118,6 +118,7 @@ JSExportAs(fireEvent,
118
118
@deprecated Only here for backwards compatibility with SDK < 8.1.0. Use `init` instead.
119
119
*/
120
120
- (id )_initWithPageContext : (id <TiEvaluator>)context __attribute__((deprecated));
121
+ - (id )_initWithPageContext : (id <TiEvaluator>)context args : (NSArray *)args __attribute__((deprecated));
121
122
122
123
// hooks for when an event listener gets added/removed
123
124
- (void )_listenerAdded : (NSString *)type count : (int )count ;
Original file line number Diff line number Diff line change @@ -112,6 +112,38 @@ - (id)_initWithPageContext:(id<TiEvaluator>)context
112
112
return [self init ];
113
113
}
114
114
115
+ - (id )_initWithPageContext : (id <TiEvaluator>)context_ args : (NSArray *)args
116
+ {
117
+ if (self = [self _initWithPageContext: context_]) {
118
+ NSDictionary *a = nil ;
119
+ NSUInteger count = [args count ];
120
+ if (count > 0 && [[args objectAtIndex: 0 ] isKindOfClass: [NSDictionary class ]]) {
121
+ a = [args objectAtIndex: 0 ];
122
+ }
123
+
124
+ // If we're being created by an old proxy/module but we're a new-style obj-c proxy
125
+ // we need to handle assigning the properties object passed into the constructor
126
+ if (a != nil ) {
127
+ // Get the JS object corresponding to "this" proxy
128
+ // Note that [JSContext currentContext] is nil, so we need to hack and get the global context
129
+ // TODO: Can we hack in a nice method that gets current context if available, falls back to global context?
130
+ // Because a lot of the code in the proxy base class assumes current context is not nil
131
+ KrollContext *krollContext = [context_ krollContext ];
132
+ JSGlobalContextRef ref = krollContext.context ;
133
+ JSValueRef jsValueRef = TiBindingTiValueFromNSObject (ref, self);
134
+ JSContext *context = [JSContext contextWithJSGlobalContextRef: ref];
135
+ JSValue *this = [JSValue valueWithJSValueRef: jsValueRef inContext: context];
136
+
137
+ // Go through the key/value pairs and set them on "this"
138
+ for (NSString *key in a) {
139
+ id value = a[key];
140
+ this[key] = value;
141
+ }
142
+ }
143
+ }
144
+ return self;
145
+ }
146
+
115
147
- (NSURL *)_baseURL
116
148
{
117
149
return baseURL;
You can’t perform that action at this time.
0 commit comments