dimanche 10 janvier 2016

swfit : Condition of not changing the date picker

I am making an app for writing notes. Simply, enter the date and contents.
When entering the date, save the datePicker value and date text together. In conclusion, the three data(datepicker.date / dateText / content) are generated. Press the Save button to save today's date. I want to change only the content. What should I do?

@IBAction func saveButton :

if stores == nil { //store: EntityName?
    new()
    } else {
    edit()
    }

new() :

    let ent = NSEntityDescription.entityForName("EntityName", inManagedObjectContext: context)
    let content = EntityName(entity: ent!, insertIntoManagedObjectContext: context)

    content.date = datePicker.date 
    content.dateText = dateLabel.text //selected datePicker -> label
    content.content = textField.text
    do { try context.save() }
    catch {
    }

edit() :

    stores!.dateText = dateLabel.text
    stores!.content = textField.text
    if (datePicker.valueForKey("Changed") != nil) { //I don't Know this is right.
        stores!.date = datePicker.date
        } else {
        }
        do { try context.save() }
        catch {
        }

Aucun commentaire:

Enregistrer un commentaire