13

I have coreData swift class defined as

import Foundation
import CoreData

@objc(Users)
public class Users: NSManagedObject {

}

Name of file is

Users+CoreDataClass.swift

I need to call this as

NSFetchRequest* request = [Users fetchRequest];

I have tried importing "Users+CoreDataClass-Swift.h" However its not recognising any class with users name.

What am i missing.

shallowThought
  • 19,212
  • 9
  • 65
  • 112
Muhammad Umar
  • 11,391
  • 21
  • 91
  • 193
  • Please describe how you have setup your Model and let us know, what your target OS is. General information about auto created `NSManagedObject` subclasses can be found [in this answer](http://stackoverflow.com/questions/39931137/xcode-is-looking-for-core-data-entity-names-with-dot-not-compiling/39933534#39933534). – shallowThought Jan 20 '17 at 06:38
  • My deployment target is 9.0. i am creating models from "Create NSManagedObject class" Its creating swift only. and i need to use these into my objective c code. – Muhammad Umar Jan 20 '17 at 06:42
  • Is it feasible for you to have the Swift classes instead of generating Obj-C classes right away? – shallowThought Jan 20 '17 at 06:46
  • Not really, i would prefer it to make Obj c classes but not sure it just auto generate Swift classes. – Muhammad Umar Jan 20 '17 at 06:47
  • [This](http://stackoverflow.com/a/38287948/1457385) should work than. – shallowThought Jan 20 '17 at 06:48
  • @shallowThought oh man, thanks so much :) – Muhammad Umar Jan 20 '17 at 06:52

1 Answers1

49

You can generate Objective-C NSManagedObject subclasses right away. To do so, change your Models settings accordingly:

shallowThought
  • 19,212
  • 9
  • 65
  • 112