Errors with the Photo() argument

I’ve just got through the “updating items” section on page 361, and have had many errors revolving around “Photo” come up, mostly in the FlickrAPI:

In enum PhotoResult, case Success([Photo]), I get a compile error where ““Photo”” is ambiguous for the type lookup in this context". I get the same error in the photoFromJSONObject func in each line Photo is used.

Also, var finalPhotos in photosFromJSONData says “Cannot invoke value of function type with argument list ‘()’”.

Could anyone give advice on what might be causing this error?


I think the first error is saying that Swift can see two different definitions of Photo, and it doesn’t know which one to use. I’m not sure how you can achieve that without getting a redefinition error. You can resolve an ambiguity like that by prefixing Photo with the correct name indicating which definition you want to employ, but that isn’t the fix you want.

Maybe that problem is a vestige of your previous problems setting up your NSManaged Object subclass files? Try:

Product>(hold Option key down)Clean Build Folder

I don’t know what the difference is between Clean and Clean Build Folder.

If that doesn’t work, see here:

This is strange… I cleaned the build folder as suggested and several of the errors disappeared, and a few were created. I managed to remove some by matching the names of the Photo class attributes with that in the NSManagedObject subclass (possible mistake earlier).

I’m left with one remaining compile error:
In the line:

photo.NSEntityDescription.insertNewObjectForEntityForName("Photo", inManagedObjectContext: context) as! Photo

The error message reads:

Value of type ‘Photo’ has no member ‘NSEntityDescription’

I can’t make my code get that error. And:

NSEntityDescription objects are primarily used by the Core Data Framework for mapping entries in the persistent store to managed objects in the application

So it might be a setup problem.

Do you know what the version 6 iOS guide says in order to address this? I have the feeling that it is wildly different.