ios - Using NSClassFromString() on a Swift declared class requires a fully qualified name -


i have issue in swift have class defined named person, , when talking objective-c code, try create new instances of class.

obviously nsclassfromstring(@"person") fails, because needs qualified name such dbaccess_test.person.

my question is, able programatically generate dbaccess_test. portion, possibly searching through registry of classes perhaps?

the reason being, orm maintain, swift programmer may decide have of storage classes within separate namespace application. wish maintain standard table naming practices match names of class understood developer.

for instance, instead of query being:

nsarray* r = [[[[person query]               where:@"surname in (select surname employees)"]              orderby:@"forename"]              fetch]; 

it become:

nsarray* r = [[[[person query]               where:@"surname in (select surname dbaccess_test_employees)"]              orderby:@"forename"]              fetch]; 

the orm has bit of identity crisis. wish keep in check table names, class names programmer use.

thanks in advance foe help.

annoyingly, stumble across answer post (despite searching hours).

you must put @objc(swiftclassname) above swift class.
like:

@objc(subclass) class subclass: superclass {...} 

then of original objective-c code see these classes , not try funky them!

thanks @klaus

original post can found here:

https://stackoverflow.com/a/24448786/846035


Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -