TWS001
2/16/2013 - 4:42 PM

iOSSnippets

iOSSnippets

CorePlotMagicalRecord
// Im Wesentlichen Coreplot stack aufsetzten. schreiben von Records und Lesen

        MagicalRecord.setupCoreDataStackWithAutoMigratingSqliteStoreNamed("myMagicTest.sqlite")
        
        var localContext :  NSManagedObjectContext = NSManagedObjectContext.MR_contextForCurrentThread()
        
        var newValue : XYValues = XYValues.MR_createInContext(localContext) as XYValues
        
        newValue.xValue = 0.0
        newValue.yValue = 9.9
        
        localContext.MR_saveOnlySelfAndWait()
        
        newValue = XYValues.MR_createInContext(localContext) as XYValues
        
        newValue.xValue = 2.0
        newValue.yValue = 11.9
        
        
        localContext.MR_saveOnlySelfAndWait()
        
        newValue = XYValues.MR_createInContext(localContext) as XYValues
        
        newValue.xValue = 3.0
        newValue.yValue = 12.9
        
        println("\n Test \(newValue.xValue!) \n")
        
        localContext.MR_saveOnlySelfAndWait()
        
        var alleValues : Array = XYValues.MR_findAll()
        
        println("\n Grösse des Array: \(alleValues.count) \n")
        
        let res1 = alleValues[2].xValue!
        let res2 = alleValues[4].xValue!
        
        
        println("\n Ein Wert 0: \(alleValues[0].xValue!) \n")
        println("\n Ein Wert 1: \(alleValues[1].xValue!) \n")
        println("\n Ein Wert 2: \(alleValues[2].xValue!!.doubleValue) \n")
        println("\n Multiplikation: \(res1!.doubleValue * res2!.doubleValue) \n")