import UIKit
import CoreData

class ViewController: UIViewController {

```
@IBAction func btnGood(sender: AnyObject) {

    var appDel:AppDelegate = (UIApplication.sharedApplication().delegate as! AppDelegate)
    var context: NSManagedObjectContext = appDel.managedObjectContext

    var record = NSEntityDescription.insertNewObjectForEntityForName("Meals", inManagedObjectContext: context) as NSManagedObject
    record.setValue(1, forKey: "data")
    do {
        try context.save()
    } catch {
        print("error")
    }
    print(record)
    print("Object Saved")

}

```

error -

```
2015-11-23 17:10:12.264 statsStoring[5355:669919] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Unacceptable type of value for attribute: property = "data"; desired type = NSString; given type = __NSCFNumber; value = 1.'
*** First throw call stack:
(
    0   CoreFoundation                      0x0000000101a3be65 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x000000010377adeb objc_exception_throw + 48
    2   CoreData                            0x00000001015d6990 _PFManagedObject_coerceValueForKeyWithDescription + 2864
    3   CoreData                            0x00000001015ae801 _sharedIMPL_setvfk_core + 177
    4   statsStoring                        0x00000001014c83ec _TFC12statsStoring14ViewController7btnGoodfS0_FPSs9AnyObject_T_ + 684
    5   statsStoring                        0x00000001014c8786 _TToFC12statsStoring14ViewController7btnGoodfS0_FPSs9AnyObject_T_ + 54
    6   UIKit                               0x000000010225c8c8 -[UIApplication sendAction:to:from:forEvent:] + 92
    7   UIKit                               0x00000001023cb328 -[UIControl sendAction:to:forEvent:] + 67
    8   UIKit                               0x00000001023cb5f4 -[UIControl _sendActionsForEvents:withEvent:] + 311
    9   UIKit                               0x00000001023ca724 -[UIControl touchesEnded:withEvent:] + 601
    10  UIKit                               0x00000001022cbbcf -[UIWindow _sendTouchesForEvent:] + 835
    11  UIKit                               0x00000001022cc904 -[UIWindow sendEvent:] + 865
    12  UIKit                               0x000000010227b29a -[UIApplication sendEvent:] + 263
    13  UIKit                               0x00000001022554cb _UIApplicationHandleEventQueue + 6844
    14  CoreFoundation                      0x0000000101967a31 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    15  CoreFoundation                      0x000000010195d95c __CFRunLoopDoSources0 + 556
    16  CoreFoundation                      0x000000010195ce13 __CFRunLoopRun + 867
    17  CoreFoundation                      0x000000010195c828 CFRunLoopRunSpecific + 488
    18  GraphicsServices                    0x00000001060b5ad2 GSEventRunModal + 161
    19  UIKit                               0x000000010225ad44 UIApplicationMain + 171
    20  statsStoring                        0x00000001014ca89d main + 109
    21  libdyld.dylib                       0x000000010429492d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

```

i want if the user pressed btngood button then '1 (true)' value should save in the 'data' attribute ! for this i tried 1 but its giving me an error and i know that its not the right way to do that