Skip to content

irekasoft/TimeTracker---CoreData-Demo-

Repository files navigation

TimeTracker

CoreData Sampler on Objective-C

This project showcase the basic (template) of CoreData on a custom framework.

CoreData has cool template on Xcode but doesn't cover the extensive version with other 'extensions'.

So on this project we also cover reading CoreData on:

  • WatchKit
  • Today's Extension

It's pretty amazing to discover that on widget and on Apple Watch we actually can add on data on the CoreData. But yet still got an issue how to make it updated on the main app.

Simple Database which has Event entity.

Event has

  • timeStamp : Date
  • title : String

iCloud Support

We have added iCloud support. Tested and seems to work. Although next refinement will coming.

NSUndoManager

This is implemented at CoreDataAccess.

We use shake motion detector to detect shake movement then undo.

[[self undoManager] undo];

Core data

We have 'upgrade' CoreData code template code to support:

  • migration
  • app groups

WatchApp

Force-touch to add new event.

Extension-ability

  1. First of all, we need to know where the part of your code that will be the core of accessing data. Make it as a framework.

New > Target.. > Framework & Library > Cocoa Touch Framework

We have it as CoreDataAccess with a shared instance called sharedInstace so you can easily call from everywhere.

The xcdatamodeld need to be on TimeTrackerKit, and make sure the target membership is checked on created targets. Such as TimeTracker (main app), WatchKit app, and Today Widget.

So wherever on class, just import #import <TimeTrackerKit/TimeTrackerKit.h> to access the data.

  1. To make CoreData extension-ability we need to turn-on 'AppGroups'. Name it 'group.yourcompany.yourapp' on each of the main app, watch kit app, and today's extension.

Issue

Issue with today view, when we start to implement iCloud support.

Well, we can add data from Widget but when we back to app, it doesnt refresh automatically. Well we can recommend that do not add data from the extension.

We had issue when the iCloud didn't work. It was because we didn't 'on' the iCloud Document. This is for CoreData.

There is problem with iCloud + CoreData. We cannot access from extention in iOS 8.

https://devforums.apple.com/message/1051015#1051015

It reads that CloudKit is the answer for distareous iCloud + CoreData.

Reference

http://www.objc.io/issue-10/icloud-core-data.html

https://developer.apple.com/library/ios/documentation/DataManagement/Conceptual/UsingCoreDataWithiCloudPG/Introduction/Introduction.html

https://developer.apple.com/library/mac/documentation/General/Conceptual/iCloudDesignGuide/Chapters/iCloudFundametals.html

Todo

Make it capable to migrate. At least minor update.


Developed by iReka Soft in Cyberjaya (www.irekasoft.com)

About

An Obj-C demo on CoreData, Framework, App Group, WatchKit

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published