{"action":"created","issue":{"url":"https://api.github.com/repos/NativeScript/ios-runtime/issues/296","labels_url":"https://api.github.com/repos/NativeScript/ios-runtime/issues/296/labels{/name}","comments_url":"https://api.github.com/repos/NativeScript/ios-runtime/issues/296/comments","events_url":"https://api.github.com/repos/NativeScript/ios-runtime/issues/296/events","html_url":"https://github.com/NativeScript/ios-runtime/issues/296","id":105814531,"number":296,"title":"Incorrect Class Conversion NSClassFromString()","user":{"login":"kivlara","id":1898070,"avatar_url":"https://avatars.githubusercontent.com/u/1898070?v=3","gravatar_id":"","url":"https://api.github.com/users/kivlara","html_url":"https://github.com/kivlara","followers_url":"https://api.github.com/users/kivlara/followers","following_url":"https://api.github.com/users/kivlara/following{/other_user}","gists_url":"https://api.github.com/users/kivlara/gists{/gist_id}","starred_url":"https://api.github.com/users/kivlara/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kivlara/subscriptions","organizations_url":"https://api.github.com/users/kivlara/orgs","repos_url":"https://api.github.com/users/kivlara/repos","events_url":"https://api.github.com/users/kivlara/events{/privacy}","received_events_url":"https://api.github.com/users/kivlara/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":21,"created_at":"2015-09-10T14:12:05Z","updated_at":"2015-09-10T19:06:23Z","closed_at":null,"body":"objc:\r\n```objective-c\r\n@interface AppDelegate : NSObject\r\n...\r\n@end\r\n\r\n@implementation AppDelegate\r\n...\r\n@end\r\n```\r\n\r\nin javascript:\r\n```javascript\r\nconsole.log(NSClassFromString(\"AppDelegate\"));\r\n```\r\nresult:\r\n```javascript\r\nfunction NSObject() {\r\n    [native code]\r\n}\r\n```\r\nI think this is an error: need to be:\r\n```javascript\r\nfunction AppDelegate() {\r\n    [native code]\r\n}\r\n```\r\nI try to use an Objective C Class declared by me, in javascript but I can't access him.\r\nI get:  ```JS ERROR ReferenceError: Can't find variable: AppDelegate```\r\nso i try to get this class from NSClassFromString.\r\n\r\nP.S: Thank you for an amazing product!"},"comment":{"url":"https://api.github.com/repos/NativeScript/ios-runtime/issues/comments/139347485","html_url":"https://github.com/NativeScript/ios-runtime/issues/296#issuecomment-139347485","issue_url":"https://api.github.com/repos/NativeScript/ios-runtime/issues/296","id":139347485,"user":{"login":"fealebenpae","id":289915,"avatar_url":"https://avatars.githubusercontent.com/u/289915?v=3","gravatar_id":"","url":"https://api.github.com/users/fealebenpae","html_url":"https://github.com/fealebenpae","followers_url":"https://api.github.com/users/fealebenpae/followers","following_url":"https://api.github.com/users/fealebenpae/following{/other_user}","gists_url":"https://api.github.com/users/fealebenpae/gists{/gist_id}","starred_url":"https://api.github.com/users/fealebenpae/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fealebenpae/subscriptions","organizations_url":"https://api.github.com/users/fealebenpae/orgs","repos_url":"https://api.github.com/users/fealebenpae/repos","events_url":"https://api.github.com/users/fealebenpae/events{/privacy}","received_events_url":"https://api.github.com/users/fealebenpae/received_events","type":"User","site_admin":false},"created_at":"2015-09-10T19:06:23Z","updated_at":"2015-09-10T19:06:23Z","body":"Hi @kivlara,\r\n\r\nThis is the intended behavior of the runtime - whenever NativeScript encounters a `Class` it will try to find it in the metadata and if it fails it will try again with its super class, and so on until it reaches a class it knows about. You can see in your app's output messages which indicate that the runtime has failed to find metadata for the `Test` class and has fallen back to `NSObject`.\r\n\r\nAccessing APIs not described in the metadata is neither supported, nor intended. In Objective-C, `[[[NSArray alloc] init] class]` will return `__NSArrayI`, but in NativeScript `NSArray.alloc().init().class()` will return `NSArray` - `__NSArrayI`'s closest parent that the metadata knows about.\r\n\r\nIf you share some details about the scenario you're trying to implement, maybe we'll be able to help out by suggesting an alternative approach."}}