ios - Type methods ignoring global scope? -


i trying write convenience method creating new object types in coredata. have managedobjectcontext defined @ global level in file.

this code looks like:

class room: nsmanagedobject {      class func createnew() -> nsmanagedobject {         return nsentitydescription.insertnewobjectforentityforname("room", inmanagedobjectcontext: managedobjectcontext!) as? nsmanagedobject     } } 

where calling managedobjectcontext error. says

room.type not have property named managedobjectcontext

yet not want data. appears in auto-complete correctly , breaks after completing.

the problem nsmangedobject has instance property same name managedobjectcontext (which of course cannot access type method).

renaming global variable should solve problem, or can refer explicit module name of app:

yourappmodulename.managedobjectcontext 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -