I am calling this function,

func createMOforEntityName<T, U >(entityName:String, 
context:NSManagedObjectContext, key:String, keyAttribute: U) -> (Bool, T) {
        
        guard let mo:T =  self.moExistsWith(entityName, key:key, keyAttribute: 
keyAttribute) else {
            
            let mo:T = 
NSEntityDescription.insertNewObjectForEntityForName(entityName, 
inManagedObjectContext: context) as! T
        
        return (false, mo)
        
        }
        
        return (true, mo)
    }


with this call:

let (already_Exists, aNewMO:ESLSizeMO) = createMOforEntityName("ESLSizeEntity", 
context: self.managedObjectContext, key:"sizeName", keyAttribute: sizeName)



In this case, sizeName is a String, but key attribute could also be a Double.  
The Error is on the calling line:

 Cannot invoke 'createMOforEntityName' with an argument list of type '(String, 
context: NSManagedObjectContext, key: String, keyAttribute: String)'

The hint says: 'Expected an argument list of type '(String, context: 
NSManagedObjectContext, key: String, keyAttribute: U)’

My question is how to call “createMOforEntityName” when  ‘U’ could either be a 
String, or a Double.

Thanks in advance.



_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to