Repository: mslathrop/SwiftNote
Branch: master
Commit: fa509afc7152
Files: 27
Total size: 92.1 KB
Directory structure:
gitextract_2kqxpr1d/
├── .gitignore
├── LICENSE
├── README.md
├── SwiftNote/
│ ├── AppDelegate.swift
│ ├── Base.lproj/
│ │ └── Main.storyboard
│ ├── Constants.swift
│ ├── CoreDataProvider.swift
│ ├── Images.xcassets/
│ │ ├── AppIcon.appiconset/
│ │ │ └── Contents.json
│ │ └── LaunchImage.launchimage/
│ │ └── Contents.json
│ ├── Info.plist
│ ├── Note.swift
│ ├── NoteDetailViewController.swift
│ ├── NoteProtocol.swift
│ ├── NotesTableViewCell.swift
│ ├── NotesTableViewController.swift
│ ├── SwiftNote.entitlements
│ ├── SwiftNote.xcdatamodeld/
│ │ ├── .xccurrentversion
│ │ └── SwiftNote.xcdatamodel/
│ │ └── contents
│ └── SwiftNoteNavigationController.swift
├── SwiftNote.xcodeproj/
│ └── project.pbxproj
├── SwiftNoteTests/
│ ├── Info.plist
│ └── SwiftNoteTests.swift
└── SwiftNoteTodayWidget/
├── Info.plist
├── MainInterface.storyboard
├── TodayTableViewCell.swift
├── TodayViewController.swift
└── com.appbrewllc.SwiftNote.SwiftNoteTodayWidget.entitlements
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
# Xcode
.DS_Store
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
*.xcworkspace
!default.xcworkspace
xcuserdata
profile
*.moved-aside
DerivedData
.idea/
#CocoaPods
#Pods
================================================
FILE: LICENSE
================================================
Copyright (c) 2014 AppBrew LLC (http://www.appbrewllc.com/)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
================================================
FILE: README.md
================================================
#SwiftNote
Note taking app with recent notes today widget and iCloud syncing. Written in swift
##Things to watch out for with the today widget
1. Make sure to set the height using self.preferredContentSize
##Sharing data between the today widget and app
1. Add an app group through the entitlements screen for both the widget and the app
2. Make sure to specify the same group for each
3. Make the core data store url exist in the app group's shared container:
```
var storeURL = NSFileManager.defaultManager().containerURLForSecurityApplicationGroupIdentifier(kAppGroupIdentifier)
storeURL = storeURL.URLByAppendingPathComponent("SwiftNote.sqlite");
```
4. Use this storeURL in both the today widget and app
##Debugging the today widget
1. Run the container app (SwiftNote) after making any changes
2. Stop debugging
3. In menu bar select Debug -> Attach to process -> By Process Identifier or Name
4. Attach to the process com.appbrewllc.SwiftNote.SwiftNoteTodayWidget
5. Breakpoint all the things!
##iCloud syncing
This is currently not working. If anyone knows how to get this working please let me know
================================================
FILE: SwiftNote/AppDelegate.swift
================================================
//
// AppDelegate.swift
// SwiftNote
//
// Created by AppBrew LLC (appbrewllc.com) on 6/3/14.
// Copyright (c) 2014 Matt Lathrop. All rights reserved.
//
import UIKit
import CoreData
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
var coreDataProvider: CoreDataProvider?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool {
// Override point for customization after application launch.
self.coreDataProvider = CoreDataProvider()
return true
}
func applicationWillResignActive(application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
func applicationDidEnterBackground(application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
func applicationWillEnterForeground(application: UIApplication) {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}
func applicationDidBecomeActive(application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
func applicationWillTerminate(application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
// Saves changes in the application's managed object context before the application terminates.
self.saveContext()
}
// #pragma mark - Core Data stack
func saveContext () {
self.coreDataProvider!.saveContext()
}
var managedObjectContext: NSManagedObjectContext {
return self.coreDataProvider!.managedObjectContext
}
var managedObjectModel: NSManagedObjectModel {
return self.coreDataProvider!.managedObjectModel
}
var persistentStoreCoordinator: NSPersistentStoreCoordinator {
return self.coreDataProvider!.persistentStoreCoordinator
}
}
================================================
FILE: SwiftNote/Base.lproj/Main.storyboard
================================================
================================================
FILE: SwiftNote/Constants.swift
================================================
//
// Constants.swift
// SwiftNote
//
// Created by Matthew Lathrop on 6/3/14.
// Copyright (c) 2014 Matt Lathrop. All rights reserved.
//
import Foundation
let kAppGroupIdentifier = "group.swiftnote.appbrewllc.com"
// Entity Names
let kEntityNameNoteEntity = "NoteEntity"
// Reuse Identifiers
let kReuseIdentifierNotesTableViewCell = "ruid_notesTableViewCell"
let kReuseIdentifierTodayTableViewCell = "ruid_todayViewCell"
// Segue Identifiers
let kSegueIdentifierNotesTableToNoteDetailAdd = "seg_notesTableToNoteDetail_add"
let kSegueIdentifierNotesTableToNoteDetailEdit = "seg_notesTableToNoteDetail_edit"
================================================
FILE: SwiftNote/CoreDataProvider.swift
================================================
//
// CoreDataProvider.swift
// SwiftNote
//
// Created by Matthew Lathrop on 6/11/14.
// Copyright (c) 2014 Matt Lathrop. All rights reserved.
//
import CoreData
class CoreDataProvider: NSObject {
var applicationDocumentsDirectory: NSURL! = {
let urls = NSFileManager.defaultManager().URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask)
return urls[urls.endIndex-1] as NSURL
}()
func saveContext () {
var error: NSError? = nil
let managedObjectContext = self.managedObjectContext
if managedObjectContext.save(&error) {
if managedObjectContext.hasChanges && !managedObjectContext.save(&error) {
// Replace this implementation with code to handle the error appropriately.
// abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
//println("Unresolved error \(error), \(error.userInfo)")
abort()
}
}
}
// #pragma mark - Core Data stack
// Returns the managed object context for the application.
// If the context doesn't already exist, it is created and bound to the persistent store coordinator for the application.
var managedObjectContext: NSManagedObjectContext {
if _managedObjectContext == nil {
_managedObjectContext = NSManagedObjectContext(concurrencyType: NSManagedObjectContextConcurrencyType.MainQueueConcurrencyType)
_managedObjectContext!.mergePolicy = NSMergeByPropertyObjectTrumpMergePolicy
_managedObjectContext!.persistentStoreCoordinator = self.persistentStoreCoordinator
}
return _managedObjectContext!
}
var _managedObjectContext: NSManagedObjectContext? = nil
// Returns the managed object model for the application.
// If the model doesn't already exist, it is created from the application's model.
var managedObjectModel: NSManagedObjectModel {
if _managedObjectModel == nil {
let modelURL = NSBundle.mainBundle().URLForResource("SwiftNote", withExtension: "momd")
_managedObjectModel = NSManagedObjectModel(contentsOfURL: modelURL!)
}
return _managedObjectModel!
}
var _managedObjectModel: NSManagedObjectModel? = nil
// Returns the persistent store coordinator for the application.
// If the coordinator doesn't already exist, it is created and the application's store added to it.
var persistentStoreCoordinator: NSPersistentStoreCoordinator {
if _persistentStoreCoordinator == nil {
// store url should point to the shared container
var storeURL = NSFileManager.defaultManager().containerURLForSecurityApplicationGroupIdentifier(kAppGroupIdentifier)
storeURL = storeURL?.URLByAppendingPathComponent("SwiftNote.sqlite")
//store url if you don't want to make a shared container.
//var storeURL = applicationDocumentsDirectory.URLByAppendingPathComponent("SwiftNote.sqlite")
var error: NSError? = nil
_persistentStoreCoordinator = NSPersistentStoreCoordinator(managedObjectModel: self.managedObjectModel)
var currentiCloudtoken = NSFileManager.defaultManager().ubiquityIdentityToken
var options: NSDictionary? = nil
if (currentiCloudtoken != nil) {
let defaultCenter = NSNotificationCenter.defaultCenter()
/*
defaultCenter.addObserver(self, selector: "storesWillChange:", name: NSPersistentStoreCoordinatorStoresWillChangeNotification, object: _persistentStoreCoordinator)
defaultCenter.addObserver(self, selector: "storesDidChange:", name: NSPersistentStoreCoordinatorStoresDidChangeNotification, object: _persistentStoreCoordinator)
defaultCenter.addObserver(self, selector: "persistentStoreDidImportUbiquitousContentChanges:", name: NSPersistentStoreDidImportUbiquitousContentChangesNotification, object: _persistentStoreCoordinator)
defaultCenter.addObserverForName(nil, object: nil, queue: nil, usingBlock: { (notification: NSNotification!) in
println("$$$$$$$$$$\n\(notification.description)\n")
})
*/
options = [ NSMigratePersistentStoresAutomaticallyOption: true, NSInferMappingModelAutomaticallyOption: true, NSPersistentStoreUbiquitousContentNameKey: "SwiftNoteiCloudStore" ]
}
else {
options = [ NSMigratePersistentStoresAutomaticallyOption: true, NSInferMappingModelAutomaticallyOption: true ]
}
if _persistentStoreCoordinator!.addPersistentStoreWithType(NSSQLiteStoreType, configuration: nil, URL: storeURL, options: nil, error: &error) == nil {
/*
Replace this implementation with code to handle the error appropriately.
abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
Typical reasons for an error here include:
* The persistent store is not accessible;
* The schema for the persistent store is incompatible with current managed object model.
Check the error message to determine what the actual problem was.
If the persistent store is not accessible, there is typically something wrong with the file path. Often, a file URL is pointing into the application's resources directory instead of a writeable directory.
If you encounter schema incompatibility errors during development, you can reduce their frequency by:
* Simply deleting the existing store:
NSFileManager.defaultManager().removeItemAtURL(storeURL, error: nil)
* Performing automatic lightweight migration by passing the following dictionary as the options parameter:
[NSMigratePersistentStoresAutomaticallyOption: true, NSInferMappingModelAutomaticallyOption: true}
Lightweight migration will only work for a limited set of schema changes; consult "Core Data Model Versioning and Data Migration Programming Guide" for details.
*/
println("Unresolved error \(error), \(error?.description)")
abort()
}
}
return _persistentStoreCoordinator!
}
var _persistentStoreCoordinator: NSPersistentStoreCoordinator? = nil
// MARK - iCloud handling
func persistentStoreDidImportUbiquitousContentChanges(notification: NSNotification!) {
println("== persistentStoreDidImportUbiquitousContentChanges ==\n")
println(notification.description)
let context = self.managedObjectContext
context.performBlock(({
context.mergeChangesFromContextDidSaveNotification(notification)
}))
}
func storesWillChange(notification: NSNotification!) {
println("== storesWillChange ==\n")
println(notification.description)
let context = self.managedObjectContext
context.performBlockAndWait(({
var error: NSError? = nil
if context.hasChanges {
let success = context.save(&error)
if (success == false && error != nil) {
println(error!.localizedDescription)
}
}
context.reset()
}))
}
func storesDidChange(notification: NSNotification!) {
println("== storesDidChange ==\n")
println(notification.description)
//TODO
}
//TODO: create coreDataDelegate protocl
}
================================================
FILE: SwiftNote/Images.xcassets/AppIcon.appiconset/Contents.json
================================================
{
"images" : [
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
================================================
FILE: SwiftNote/Images.xcassets/LaunchImage.launchimage/Contents.json
================================================
{
"images" : [
{
"orientation" : "portrait",
"idiom" : "iphone",
"extent" : "full-screen",
"minimum-system-version" : "7.0",
"scale" : "2x"
},
{
"orientation" : "portrait",
"idiom" : "iphone",
"subtype" : "retina4",
"extent" : "full-screen",
"minimum-system-version" : "7.0",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
================================================
FILE: SwiftNote/Info.plist
================================================
CFBundleDevelopmentRegion
en
CFBundleExecutable
${EXECUTABLE_NAME}
CFBundleIdentifier
com.appbrewllc.${PRODUCT_NAME:rfc1034identifier}
CFBundleInfoDictionaryVersion
6.0
CFBundleName
${PRODUCT_NAME}
CFBundlePackageType
APPL
CFBundleShortVersionString
1.0
CFBundleSignature
????
CFBundleVersion
1
LSRequiresIPhoneOS
UIMainStoryboardFile
Main
UIRequiredDeviceCapabilities
armv7
================================================
FILE: SwiftNote/Note.swift
================================================
//
// Note.swift
// SwiftNote
//
// Created by AppBrew LLC (appbrewllc.com) on 6/3/14.
// Copyright (c) 2014 Matt Lathrop. All rights reserved.
//
import CoreData
import UIKit
class Note: NoteProtocol {
var noteEntity: NSManagedObject? = nil
var body: NSString? {
get {
return self.noteEntity!.valueForKey("body") as NSString!
}
set {
self.noteEntity!.setValue(newValue, forKey: "body")
}
}
var createdAt: NSDate? {
get {
return self.noteEntity!.valueForKey("createdAt") as NSDate!
}
set {
self.noteEntity!.setValue(newValue, forKey: "createdAt")
}
}
var entityId: NSString? {
get {
return self.noteEntity!.valueForKey("entityId") as NSString!
}
set {
self.noteEntity!.setValue(newValue, forKey: "entityId")
}
}
var modifiedAt: NSDate? {
get {
return self.noteEntity!.valueForKey("modifiedAt") as NSDate!
}
set {
self.noteEntity!.setValue(newValue, forKey: "modifiedAt")
}
}
var title: NSString? {
get {
return self.noteEntity!.valueForKey("title") as NSString!
}
set {
self.noteEntity!.setValue(newValue, forKey: "title")
}
}
class func insertNewNoteInManagedObjectContext(managedObjectContext: NSManagedObjectContext!) -> NoteProtocol {
let note = Note()
// create new entity
note.noteEntity = NSEntityDescription.insertNewObjectForEntityForName(kEntityNameNoteEntity, inManagedObjectContext: managedObjectContext) as? NSManagedObject
// set defaults
note.createdAt = NSDate.init()
note.modifiedAt = note.createdAt
note.entityId = NSUUID.init().UUIDString
return note
}
class func noteFromNoteEntity(noteEntity: NSManagedObject) -> NoteProtocol {
let note = Note()
note.noteEntity = noteEntity
return note
}
func update(#title: String, body: String) {
self.title = title;
self.body = body;
self.modifiedAt = NSDate.init()
}
func deleteInManagedObjectContext(managedObjectContext: NSManagedObjectContext!) {
managedObjectContext.deleteObject(self.noteEntity!)
}
}
================================================
FILE: SwiftNote/NoteDetailViewController.swift
================================================
//
// NoteDetailViewController.swift
// SwiftNote
//
// Created by Matthew Lathrop on 6/3/14.
// Copyright (c) 2014 Matt Lathrop. All rights reserved.
//
import CoreData
import UIKit
class NoteDetailViewController: UIViewController, UITextViewDelegate {
// MARK: properties
@IBOutlet var titleTextField: UITextField!
@IBOutlet var bodyTextView: UITextView!
@IBOutlet var tapToEditTextField: UITextField!
var note: NoteProtocol?
var saveNeeded: Bool
// MARK: methods
required init(coder aDecoder: NSCoder) {
saveNeeded = false
super.init(coder: aDecoder)
}
// MARK: view methods
override func viewDidLoad() {
super.viewDidLoad()
// fix default content inset
self.bodyTextView?.contentInset = UIEdgeInsetsMake(-10,-4,0,-4)
self.configureView()
}
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
// observe keyboard events
NSNotificationCenter.defaultCenter().addObserver(self, selector: "keyboardWillShow:", name: UIKeyboardWillShowNotification, object: nil)
NSNotificationCenter.defaultCenter().addObserver(self, selector: "keyboardWillHide:", name: UIKeyboardWillHideNotification, object: nil)
}
override func viewWillDisappear(animated: Bool) {
super.viewWillDisappear(animated)
self.updateNote()
// remove keyboard observation
NSNotificationCenter.defaultCenter().removeObserver(self, name:UIKeyboardWillShowNotification, object:nil)
NSNotificationCenter.defaultCenter().removeObserver(self, name:UIKeyboardWillHideNotification, object:nil)
}
override func viewDidDisappear(animated: Bool) {
super.viewDidDisappear(animated)
if self.saveNeeded {
(UIApplication.sharedApplication().delegate as AppDelegate).saveContext()
}
}
func configureView() {
if note != nil {
// show the right bar button item
//self.navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.Action, target: self, action: "actionButtonTapped:")
self.titleTextField.text = note?.title
self.bodyTextView.text = note?.body
}
self.hideTapToEditLabelIfNeeded()
}
// MARK - textk view delegate methods
func textViewDidBeginEditing(textView: UITextView!) {
self.tapToEditTextField.hidden = true
}
func textViewDidEndEditing(textView: UITextView!) {
self.tapToEditTextField.hidden = true
}
func textViewDidChange(textView: UITextView!) {
self.showTextViewCaretPosition(textView)
}
func textViewDidChangeSelection(textView: UITextView!) {
self.showTextViewCaretPosition(textView)
}
// MARK - keyboard notifications
func keyboardWillShow(notification: NSNotification) {
let frameValue = notification.userInfo![UIKeyboardFrameEndUserInfoKey] as NSValue
let keyboardFrame = frameValue.CGRectValue()
let animationDuration = notification.userInfo![UIKeyboardAnimationDurationUserInfoKey] as NSNumber
let isPortrait = UIDeviceOrientationIsPortrait(UIDevice.currentDevice().orientation)
let keyboardHeight = isPortrait ? keyboardFrame.size.height : keyboardFrame.size.width
var contentInset = self.bodyTextView.contentInset
contentInset.bottom = keyboardHeight
var scrollIndicatorInsets = self.bodyTextView.scrollIndicatorInsets
scrollIndicatorInsets.bottom = keyboardHeight
UIView.animateWithDuration(animationDuration.doubleValue, animations:({
self.bodyTextView.contentInset = contentInset
self.bodyTextView.scrollIndicatorInsets = scrollIndicatorInsets
})
)
}
func keyboardWillHide(notification: NSNotification) {
let animationDuration = notification.userInfo![UIKeyboardAnimationDurationUserInfoKey] as NSNumber
var contentInset = self.bodyTextView.contentInset
contentInset.bottom = 0
var scrollIndicatorInsets = self.bodyTextView.scrollIndicatorInsets
scrollIndicatorInsets.bottom = 0
UIView.animateWithDuration(animationDuration.doubleValue, animations:({
self.bodyTextView.contentInset = contentInset
self.bodyTextView.scrollIndicatorInsets = scrollIndicatorInsets
})
)
}
// MARK - other methods
func updateNote() {
var trimmedTitle = self.titleTextField.text.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceCharacterSet())
var trimmedBody = self.bodyTextView.text.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceCharacterSet())
// delete note if both fields are blank
if (note != nil && trimmedBody.isEmpty && trimmedTitle.isEmpty) {
note!.deleteInManagedObjectContext((UIApplication.sharedApplication().delegate as AppDelegate).managedObjectContext)
}
// don't do anything if fields are empty
if (trimmedBody.isEmpty && trimmedTitle.isEmpty) {
return
}
// set default title if needed
if trimmedTitle.isEmpty {
trimmedTitle = "Untitled"
}
// set default body if needed
if trimmedBody.isEmpty {
trimmedBody = "New note"
}
// return if values are the same
if (note != nil && self.note!.title == self.titleTextField.text && self.note!.body == self.bodyTextView.text) {
return
}
// save is needed by this point
self.saveNeeded = true
if note == nil {
note = Note.insertNewNoteInManagedObjectContext((UIApplication.sharedApplication().delegate as AppDelegate).managedObjectContext)
}
note?.update(title: trimmedTitle, body: trimmedBody)
}
override func didRotateFromInterfaceOrientation(fromInterfaceOrientation: UIInterfaceOrientation) {
self.showTextViewCaretPosition(self.bodyTextView)
}
func showTextViewCaretPosition(textView: UITextView!) {
let caretRect = textView.caretRectForPosition(textView.selectedTextRange!.end)
textView.scrollRectToVisible(caretRect, animated: false)
}
func hideTapToEditLabelIfNeeded() {
if (self.bodyTextView.text.utf16Count > 0) {
self.tapToEditTextField.hidden = true
}
else {
self.tapToEditTextField.hidden = false
}
}
func actionButtonTapped(sender: UIBarButtonItem!) {
//TODO:
// let activityIndicator = UIActivityIndicatorView(activityIndicatorStyle: UIActivityIndicatorViewStyle.White)
// activityIndicator.startAnimating()
//
// self.navigationItem.rightBarButtonItem.customView = activityIndicator
//
// dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ({
// let avd = UIActivityViewController(activityItems: "\(self.titleTextField.text)\(self.bodyTextView.text)", applicationActivities: nil)
// }))
}
}
================================================
FILE: SwiftNote/NoteProtocol.swift
================================================
//
// NoteProtocol.swift
// SwiftNote
//
// Created by Matthew Lathrop on 6/4/14.
// Copyright (c) 2014 Matt Lathrop. All rights reserved.
//
import CoreData
import Foundation
protocol NoteProtocol {
var body: NSString? { get set }
var createdAt: NSDate? { get set }
var entityId: NSString? { get set }
var modifiedAt: NSDate? { get set }
var title: NSString? { get set }
// class methods
class func insertNewNoteInManagedObjectContext(managedObjectContext: NSManagedObjectContext!) -> NoteProtocol
class func noteFromNoteEntity(noteEntity: NSManagedObject) -> NoteProtocol
// instance methods
func update(#title: String, body: String)
func deleteInManagedObjectContext(managedObjectContext: NSManagedObjectContext!)
}
================================================
FILE: SwiftNote/NotesTableViewCell.swift
================================================
//
// NotesTableViewCell.swift
// SwiftNote
//
// Created by Matthew Lathrop on 6/4/14.
// Copyright (c) 2014 Matt Lathrop. All rights reserved.
//
import UIKit
class NotesTableViewCell: UITableViewCell {
@IBOutlet var titleLabel: UILabel!
@IBOutlet var bodyLabel: UILabel!
func configure(#note:NoteProtocol!, indexPath:NSIndexPath!) {
self.titleLabel.text = note.title;
self.bodyLabel.text = note.body;
}
}
================================================
FILE: SwiftNote/NotesTableViewController.swift
================================================
//
// NotesTableViewController.swift
// SwiftNote
//
// Created by AppBrew LLC (appbrewllc.com) on 6/3/14.
// Copyright (c) 2014 Matt Lathrop. All rights reserved.
//
import CoreData
import UIKit
class NotesTableViewController: UITableViewController, NSFetchedResultsControllerDelegate {
var managedObjectContext: NSManagedObjectContext {
get {
if !(_managedObjectContext != nil) {
_managedObjectContext = (UIApplication.sharedApplication().delegate as AppDelegate).managedObjectContext
}
return _managedObjectContext!
}
}
var _managedObjectContext: NSManagedObjectContext? = nil
var fetchedResultsController: NSFetchedResultsController {
get {
if !(_fetchedResultsController != nil) {
// set up fetch request
var fetchRequest = NSFetchRequest()
fetchRequest.entity = NSEntityDescription.entityForName(kEntityNameNoteEntity, inManagedObjectContext: (UIApplication.sharedApplication().delegate as AppDelegate).managedObjectContext)
// sort by last updated
var sortDescriptor = NSSortDescriptor(key: "modifiedAt", ascending: false)
fetchRequest.sortDescriptors = [sortDescriptor]
fetchRequest.fetchBatchSize = 20
_fetchedResultsController = NSFetchedResultsController(fetchRequest: fetchRequest, managedObjectContext: (UIApplication.sharedApplication().delegate as AppDelegate).managedObjectContext, sectionNameKeyPath: nil, cacheName: "allNotesCache")
_fetchedResultsController!.delegate = self
}
return _fetchedResultsController!;
}
}
var _fetchedResultsController: NSFetchedResultsController? = nil
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
override func viewDidLoad() {
super.viewDidLoad()
self.fetchedResultsController.performFetch(nil)
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject!) {
if (segue.identifier == kSegueIdentifierNotesTableToNoteDetailEdit) {
let entity = self.fetchedResultsController.objectAtIndexPath(self.tableView.indexPathForSelectedRow()!) as NSManagedObject
let note = Note.noteFromNoteEntity(entity)
let viewController = segue.destinationViewController as NoteDetailViewController
viewController.note = note
}
}
// #pragma mark - Table view data source
override func numberOfSectionsInTableView(tableView: UITableView?) -> Int {
return self.fetchedResultsController.sections!.count
}
override func tableView(tableView: UITableView?, numberOfRowsInSection section: Int) -> Int {
let sectionInfo = self.fetchedResultsController.sections?[section] as NSFetchedResultsSectionInfo
return sectionInfo.numberOfObjects
}
override func tableView(_: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier(kReuseIdentifierNotesTableViewCell, forIndexPath: indexPath) as NotesTableViewCell
let entity = self.fetchedResultsController.objectAtIndexPath(indexPath) as NSManagedObject
let note = Note.noteFromNoteEntity(entity)
cell.configure(note: note, indexPath: indexPath)
return cell
}
override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
return 70
}
override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
let entity = self.fetchedResultsController.objectAtIndexPath(indexPath) as NSManagedObject
let note = Note.noteFromNoteEntity(entity)
note.deleteInManagedObjectContext((UIApplication.sharedApplication().delegate as AppDelegate).managedObjectContext)
(UIApplication.sharedApplication().delegate as AppDelegate).saveContext()
}
// MARK: - fetched results controller delegate
func controllerWillChangeContent(controller: NSFetchedResultsController) {
self.tableView.beginUpdates()
}
func controller(controller: NSFetchedResultsController, didChangeSection sectionInfo: NSFetchedResultsSectionInfo, atIndex sectionIndex: Int, forChangeType type: NSFetchedResultsChangeType) {
switch type {
case .Insert:
self.tableView.insertSections(NSIndexSet(index: sectionIndex), withRowAnimation: .Fade)
case .Delete:
self.tableView.deleteSections(NSIndexSet(index: sectionIndex), withRowAnimation: .Fade)
default:
return
}
}
func controller(controller: NSFetchedResultsController, didChangeObject anObject: AnyObject, atIndexPath indexPath: NSIndexPath, forChangeType type: NSFetchedResultsChangeType, newIndexPath: NSIndexPath) {
switch type {
case .Insert:
tableView.insertRowsAtIndexPaths([newIndexPath], withRowAnimation: .Fade)
case .Delete:
tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade)
case .Update:
let cell = tableView.cellForRowAtIndexPath(indexPath) as NotesTableViewCell
let note = self.fetchedResultsController.sections?[indexPath.section][indexPath.row] as Note
cell.configure(note: note, indexPath: indexPath)
case .Move:
tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade)
tableView.insertRowsAtIndexPaths([newIndexPath], withRowAnimation: .Fade)
default:
return
}
}
func controllerDidChangeContent(controller: NSFetchedResultsController) {
self.tableView.endUpdates()
}
}
================================================
FILE: SwiftNote/SwiftNote.entitlements
================================================
com.apple.developer.ubiquity-container-identifiers
iCloud.com.appbrewllc.SwiftNote
com.apple.security.application-groups
group.swiftnote.appbrewllc.com
================================================
FILE: SwiftNote/SwiftNote.xcdatamodeld/.xccurrentversion
================================================
_XCCurrentVersionName
SwiftNote.xcdatamodel
================================================
FILE: SwiftNote/SwiftNote.xcdatamodeld/SwiftNote.xcdatamodel/contents
================================================
================================================
FILE: SwiftNote/SwiftNoteNavigationController.swift
================================================
//
// SwiftNoteNavigationController.swift
// SwiftNote
//
// Created by AppBrew LLC (appbrewllc.com) on 6/3/14.
// Copyright (c) 2014 Matt Lathrop. All rights reserved.
//
import UIKit
class SwiftNoteNavigationController: UINavigationController {
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
/*
// #pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepareForSegue(segue: UIStoryboardSegue?, sender: AnyObject?) {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
}
================================================
FILE: SwiftNote.xcodeproj/project.pbxproj
================================================
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
660F9719194C0EA3009D2ED5 /* SwiftNote.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 6640500D193E879D00428301 /* SwiftNote.xcdatamodeld */; };
660F9720194C1F88009D2ED5 /* TodayViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 660F971E194C1F88009D2ED5 /* TodayViewController.swift */; };
660F9721194C1F88009D2ED5 /* MainInterface.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 660F971F194C1F88009D2ED5 /* MainInterface.storyboard */; };
660F9723194D3345009D2ED5 /* TodayTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 660F9722194D3345009D2ED5 /* TodayTableViewCell.swift */; };
6640500C193E879D00428301 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6640500B193E879D00428301 /* AppDelegate.swift */; };
6640500F193E879D00428301 /* SwiftNote.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 6640500D193E879D00428301 /* SwiftNote.xcdatamodeld */; };
66405014193E879D00428301 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 66405012193E879D00428301 /* Main.storyboard */; };
66405016193E879D00428301 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 66405015193E879D00428301 /* Images.xcassets */; };
66405022193E879D00428301 /* SwiftNoteTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66405021193E879D00428301 /* SwiftNoteTests.swift */; };
66405035193E8EF100428301 /* Note.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66405034193E8EF100428301 /* Note.swift */; };
66405037193E905500428301 /* SwiftNoteNavigationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66405036193E905500428301 /* SwiftNoteNavigationController.swift */; };
66405039193E910C00428301 /* NotesTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66405038193E910C00428301 /* NotesTableViewController.swift */; };
6640503B193E966800428301 /* NoteDetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6640503A193E966800428301 /* NoteDetailViewController.swift */; };
6640503E193E971C00428301 /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6640503D193E971C00428301 /* Constants.swift */; };
66405040193ED49600428301 /* NoteProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6640503F193ED49600428301 /* NoteProtocol.swift */; };
66405043193EEF2700428301 /* NotesTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66405042193EEF2700428301 /* NotesTableViewCell.swift */; };
666EB8AE1941B1B200733680 /* NotificationCenter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 666EB8AD1941B1B200733680 /* NotificationCenter.framework */; };
666EB8B81941B1B200733680 /* com.appbrewllc.SwiftNote.SwiftNoteTodayWidget.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 666EB8AB1941B1B200733680 /* com.appbrewllc.SwiftNote.SwiftNoteTodayWidget.appex */; };
666EB8CA1942417500733680 /* Note.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66405034193E8EF100428301 /* Note.swift */; };
666EB8CB1942417800733680 /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6640503D193E971C00428301 /* Constants.swift */; };
666EB8CC1942417A00733680 /* NoteProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6640503F193ED49600428301 /* NoteProtocol.swift */; };
66B045BD19495C1400092238 /* CoreDataProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66B045BC19495C1400092238 /* CoreDataProvider.swift */; };
66B045BE19495C1400092238 /* CoreDataProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66B045BC19495C1400092238 /* CoreDataProvider.swift */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
6640501C193E879D00428301 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 66404FFE193E879D00428301 /* Project object */;
proxyType = 1;
remoteGlobalIDString = 66405005193E879D00428301;
remoteInfo = SwiftNote;
};
666EB8B61941B1B200733680 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 66404FFE193E879D00428301 /* Project object */;
proxyType = 1;
remoteGlobalIDString = 666EB8AA1941B1B200733680;
remoteInfo = SwiftNoteTodayWidget;
};
666EB8B91941B1B200733680 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 66404FFE193E879D00428301 /* Project object */;
proxyType = 1;
remoteGlobalIDString = 666EB8AA1941B1B200733680;
remoteInfo = SwiftNoteTodayWidget;
};
666EB8BF1941B1C000733680 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 66404FFE193E879D00428301 /* Project object */;
proxyType = 1;
remoteGlobalIDString = 66405005193E879D00428301;
remoteInfo = SwiftNote;
};
666EB8C11941B1C000733680 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 66404FFE193E879D00428301 /* Project object */;
proxyType = 1;
remoteGlobalIDString = 66405005193E879D00428301;
remoteInfo = SwiftNote;
};
/* End PBXContainerItemProxy section */
/* Begin PBXCopyFilesBuildPhase section */
666EB8BE1941B1B200733680 /* Embed App Extensions */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "";
dstSubfolderSpec = 13;
files = (
666EB8B81941B1B200733680 /* com.appbrewllc.SwiftNote.SwiftNoteTodayWidget.appex in Embed App Extensions */,
);
name = "Embed App Extensions";
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
660F971E194C1F88009D2ED5 /* TodayViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TodayViewController.swift; sourceTree = ""; };
660F971F194C1F88009D2ED5 /* MainInterface.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = MainInterface.storyboard; sourceTree = ""; };
660F9722194D3345009D2ED5 /* TodayTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TodayTableViewCell.swift; sourceTree = ""; };
66405006193E879D00428301 /* SwiftNote.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SwiftNote.app; sourceTree = BUILT_PRODUCTS_DIR; };
6640500A193E879D00428301 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
6640500B193E879D00428301 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; };
6640500E193E879D00428301 /* SwiftNote.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = SwiftNote.xcdatamodel; sourceTree = ""; };
66405013193E879D00428301 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
66405015193E879D00428301 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; };
6640501B193E879D00428301 /* SwiftNoteTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SwiftNoteTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
66405020193E879D00428301 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
66405021193E879D00428301 /* SwiftNoteTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftNoteTests.swift; sourceTree = ""; };
66405034193E8EF100428301 /* Note.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Note.swift; sourceTree = ""; };
66405036193E905500428301 /* SwiftNoteNavigationController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwiftNoteNavigationController.swift; sourceTree = ""; };
66405038193E910C00428301 /* NotesTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NotesTableViewController.swift; sourceTree = ""; };
6640503A193E966800428301 /* NoteDetailViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NoteDetailViewController.swift; sourceTree = ""; };
6640503D193E971C00428301 /* Constants.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Constants.swift; sourceTree = ""; };
6640503F193ED49600428301 /* NoteProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NoteProtocol.swift; sourceTree = ""; };
66405042193EEF2700428301 /* NotesTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NotesTableViewCell.swift; sourceTree = ""; };
666EB8A419419F9800733680 /* SwiftNote.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = SwiftNote.entitlements; sourceTree = ""; };
666EB8AB1941B1B200733680 /* com.appbrewllc.SwiftNote.SwiftNoteTodayWidget.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = com.appbrewllc.SwiftNote.SwiftNoteTodayWidget.appex; sourceTree = BUILT_PRODUCTS_DIR; };
666EB8AD1941B1B200733680 /* NotificationCenter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = NotificationCenter.framework; path = System/Library/Frameworks/NotificationCenter.framework; sourceTree = SDKROOT; };
666EB8B11941B1B200733680 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
66B045BC19495C1400092238 /* CoreDataProvider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CoreDataProvider.swift; sourceTree = ""; };
66B045BF1949648200092238 /* com.appbrewllc.SwiftNote.SwiftNoteTodayWidget.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = com.appbrewllc.SwiftNote.SwiftNoteTodayWidget.entitlements; sourceTree = ""; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
66405003193E879D00428301 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
66405018193E879D00428301 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
666EB8A81941B1B200733680 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
666EB8AE1941B1B200733680 /* NotificationCenter.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
66404FFD193E879D00428301 = {
isa = PBXGroup;
children = (
666EB8C7194240E300733680 /* Common */,
66405008193E879D00428301 /* SwiftNote */,
6640501E193E879D00428301 /* SwiftNoteTests */,
666EB8AF1941B1B200733680 /* SwiftNoteTodayWidget */,
666EB8AC1941B1B200733680 /* Frameworks */,
66405007193E879D00428301 /* Products */,
);
sourceTree = "";
};
66405007193E879D00428301 /* Products */ = {
isa = PBXGroup;
children = (
66405006193E879D00428301 /* SwiftNote.app */,
6640501B193E879D00428301 /* SwiftNoteTests.xctest */,
666EB8AB1941B1B200733680 /* com.appbrewllc.SwiftNote.SwiftNoteTodayWidget.appex */,
);
name = Products;
sourceTree = "";
};
66405008193E879D00428301 /* SwiftNote */ = {
isa = PBXGroup;
children = (
6640500B193E879D00428301 /* AppDelegate.swift */,
6640500D193E879D00428301 /* SwiftNote.xcdatamodeld */,
6640502B193E8D8800428301 /* Controllers */,
6640502F193E8E0000428301 /* Views */,
66405015193E879D00428301 /* Images.xcassets */,
66405009193E879D00428301 /* Supporting Files */,
);
path = SwiftNote;
sourceTree = "";
};
66405009193E879D00428301 /* Supporting Files */ = {
isa = PBXGroup;
children = (
6640500A193E879D00428301 /* Info.plist */,
666EB8A419419F9800733680 /* SwiftNote.entitlements */,
);
name = "Supporting Files";
sourceTree = "";
};
6640501E193E879D00428301 /* SwiftNoteTests */ = {
isa = PBXGroup;
children = (
66405021193E879D00428301 /* SwiftNoteTests.swift */,
6640501F193E879D00428301 /* Supporting Files */,
);
path = SwiftNoteTests;
sourceTree = "";
};
6640501F193E879D00428301 /* Supporting Files */ = {
isa = PBXGroup;
children = (
66405020193E879D00428301 /* Info.plist */,
);
name = "Supporting Files";
sourceTree = "";
};
6640502B193E8D8800428301 /* Controllers */ = {
isa = PBXGroup;
children = (
6640503A193E966800428301 /* NoteDetailViewController.swift */,
66405038193E910C00428301 /* NotesTableViewController.swift */,
66405036193E905500428301 /* SwiftNoteNavigationController.swift */,
);
name = Controllers;
sourceTree = "";
};
6640502D193E8DF200428301 /* Models */ = {
isa = PBXGroup;
children = (
66405034193E8EF100428301 /* Note.swift */,
);
name = Models;
path = SwiftNote;
sourceTree = "";
};
6640502E193E8DF900428301 /* Protocols */ = {
isa = PBXGroup;
children = (
6640503F193ED49600428301 /* NoteProtocol.swift */,
);
name = Protocols;
path = SwiftNote;
sourceTree = "";
};
6640502F193E8E0000428301 /* Views */ = {
isa = PBXGroup;
children = (
66405012193E879D00428301 /* Main.storyboard */,
66405042193EEF2700428301 /* NotesTableViewCell.swift */,
);
name = Views;
sourceTree = "";
};
6640503C193E96FE00428301 /* Other */ = {
isa = PBXGroup;
children = (
6640503D193E971C00428301 /* Constants.swift */,
66B045BC19495C1400092238 /* CoreDataProvider.swift */,
);
name = Other;
path = SwiftNote;
sourceTree = "";
};
666EB8AC1941B1B200733680 /* Frameworks */ = {
isa = PBXGroup;
children = (
666EB8AD1941B1B200733680 /* NotificationCenter.framework */,
);
name = Frameworks;
sourceTree = "";
};
666EB8AF1941B1B200733680 /* SwiftNoteTodayWidget */ = {
isa = PBXGroup;
children = (
66B045BF1949648200092238 /* com.appbrewllc.SwiftNote.SwiftNoteTodayWidget.entitlements */,
660F971F194C1F88009D2ED5 /* MainInterface.storyboard */,
660F9722194D3345009D2ED5 /* TodayTableViewCell.swift */,
660F971E194C1F88009D2ED5 /* TodayViewController.swift */,
666EB8B01941B1B200733680 /* Supporting Files */,
);
path = SwiftNoteTodayWidget;
sourceTree = "";
};
666EB8B01941B1B200733680 /* Supporting Files */ = {
isa = PBXGroup;
children = (
666EB8B11941B1B200733680 /* Info.plist */,
);
name = "Supporting Files";
sourceTree = "";
};
666EB8C7194240E300733680 /* Common */ = {
isa = PBXGroup;
children = (
6640502D193E8DF200428301 /* Models */,
6640503C193E96FE00428301 /* Other */,
6640502E193E8DF900428301 /* Protocols */,
);
name = Common;
sourceTree = "";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
66405005193E879D00428301 /* SwiftNote */ = {
isa = PBXNativeTarget;
buildConfigurationList = 66405025193E879D00428301 /* Build configuration list for PBXNativeTarget "SwiftNote" */;
buildPhases = (
66405002193E879D00428301 /* Sources */,
66405003193E879D00428301 /* Frameworks */,
66405004193E879D00428301 /* Resources */,
666EB8BE1941B1B200733680 /* Embed App Extensions */,
);
buildRules = (
);
dependencies = (
666EB8B71941B1B200733680 /* PBXTargetDependency */,
666EB8BA1941B1B200733680 /* PBXTargetDependency */,
);
name = SwiftNote;
productName = SwiftNote;
productReference = 66405006193E879D00428301 /* SwiftNote.app */;
productType = "com.apple.product-type.application";
};
6640501A193E879D00428301 /* SwiftNoteTests */ = {
isa = PBXNativeTarget;
buildConfigurationList = 66405028193E879D00428301 /* Build configuration list for PBXNativeTarget "SwiftNoteTests" */;
buildPhases = (
66405017193E879D00428301 /* Sources */,
66405018193E879D00428301 /* Frameworks */,
66405019193E879D00428301 /* Resources */,
);
buildRules = (
);
dependencies = (
6640501D193E879D00428301 /* PBXTargetDependency */,
666EB8C01941B1C000733680 /* PBXTargetDependency */,
666EB8C21941B1C000733680 /* PBXTargetDependency */,
);
name = SwiftNoteTests;
productName = SwiftNoteTests;
productReference = 6640501B193E879D00428301 /* SwiftNoteTests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
666EB8AA1941B1B200733680 /* SwiftNoteTodayWidget */ = {
isa = PBXNativeTarget;
buildConfigurationList = 666EB8BB1941B1B200733680 /* Build configuration list for PBXNativeTarget "SwiftNoteTodayWidget" */;
buildPhases = (
666EB8A71941B1B200733680 /* Sources */,
666EB8A81941B1B200733680 /* Frameworks */,
666EB8A91941B1B200733680 /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = SwiftNoteTodayWidget;
productName = SwiftNoteTodayWidget;
productReference = 666EB8AB1941B1B200733680 /* com.appbrewllc.SwiftNote.SwiftNoteTodayWidget.appex */;
productType = "com.apple.product-type.app-extension";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
66404FFE193E879D00428301 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0600;
ORGANIZATIONNAME = "Matt Lathrop";
TargetAttributes = {
66405005193E879D00428301 = {
CreatedOnToolsVersion = 6.0;
DevelopmentTeam = U379US498J;
SystemCapabilities = {
com.apple.iCloud = {
enabled = 1;
};
com.apple.iOS = {
enabled = 1;
};
};
};
6640501A193E879D00428301 = {
CreatedOnToolsVersion = 6.0;
TestTargetID = 66405005193E879D00428301;
};
666EB8AA1941B1B200733680 = {
CreatedOnToolsVersion = 6.0;
DevelopmentTeam = U379US498J;
SystemCapabilities = {
com.apple.iOS = {
enabled = 1;
};
};
};
};
};
buildConfigurationList = 66405001193E879D00428301 /* Build configuration list for PBXProject "SwiftNote" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = 66404FFD193E879D00428301;
productRefGroup = 66405007193E879D00428301 /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
66405005193E879D00428301 /* SwiftNote */,
6640501A193E879D00428301 /* SwiftNoteTests */,
666EB8AA1941B1B200733680 /* SwiftNoteTodayWidget */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
66405004193E879D00428301 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
66405014193E879D00428301 /* Main.storyboard in Resources */,
66405016193E879D00428301 /* Images.xcassets in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
66405019193E879D00428301 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
666EB8A91941B1B200733680 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
660F9721194C1F88009D2ED5 /* MainInterface.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
66405002193E879D00428301 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
6640500C193E879D00428301 /* AppDelegate.swift in Sources */,
66405037193E905500428301 /* SwiftNoteNavigationController.swift in Sources */,
6640500F193E879D00428301 /* SwiftNote.xcdatamodeld in Sources */,
66405035193E8EF100428301 /* Note.swift in Sources */,
6640503E193E971C00428301 /* Constants.swift in Sources */,
66405040193ED49600428301 /* NoteProtocol.swift in Sources */,
66405039193E910C00428301 /* NotesTableViewController.swift in Sources */,
6640503B193E966800428301 /* NoteDetailViewController.swift in Sources */,
66405043193EEF2700428301 /* NotesTableViewCell.swift in Sources */,
66B045BD19495C1400092238 /* CoreDataProvider.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
66405017193E879D00428301 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
66405022193E879D00428301 /* SwiftNoteTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
666EB8A71941B1B200733680 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
666EB8CB1942417800733680 /* Constants.swift in Sources */,
660F9719194C0EA3009D2ED5 /* SwiftNote.xcdatamodeld in Sources */,
660F9720194C1F88009D2ED5 /* TodayViewController.swift in Sources */,
660F9723194D3345009D2ED5 /* TodayTableViewCell.swift in Sources */,
66B045BE19495C1400092238 /* CoreDataProvider.swift in Sources */,
666EB8CA1942417500733680 /* Note.swift in Sources */,
666EB8CC1942417A00733680 /* NoteProtocol.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */
6640501D193E879D00428301 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 66405005193E879D00428301 /* SwiftNote */;
targetProxy = 6640501C193E879D00428301 /* PBXContainerItemProxy */;
};
666EB8B71941B1B200733680 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 666EB8AA1941B1B200733680 /* SwiftNoteTodayWidget */;
targetProxy = 666EB8B61941B1B200733680 /* PBXContainerItemProxy */;
};
666EB8BA1941B1B200733680 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 666EB8AA1941B1B200733680 /* SwiftNoteTodayWidget */;
targetProxy = 666EB8B91941B1B200733680 /* PBXContainerItemProxy */;
};
666EB8C01941B1C000733680 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 66405005193E879D00428301 /* SwiftNote */;
targetProxy = 666EB8BF1941B1C000733680 /* PBXContainerItemProxy */;
};
666EB8C21941B1C000733680 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 66405005193E879D00428301 /* SwiftNote */;
targetProxy = 666EB8C11941B1C000733680 /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
/* Begin PBXVariantGroup section */
66405012193E879D00428301 /* Main.storyboard */ = {
isa = PBXVariantGroup;
children = (
66405013193E879D00428301 /* Base */,
);
name = Main.storyboard;
sourceTree = "";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
66405023193E879D00428301 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
METAL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
};
name = Debug;
};
66405024193E879D00428301 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = YES;
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
METAL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES;
};
name = Release;
};
66405026193E879D00428301 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = SwiftNote/SwiftNote.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
INFOPLIST_FILE = SwiftNote/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
};
name = Debug;
};
66405027193E879D00428301 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = SwiftNote/SwiftNote.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
INFOPLIST_FILE = SwiftNote/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
};
name = Release;
};
66405029193E879D00428301 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/SwiftNote.app/SwiftNote";
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
"$(inherited)",
);
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
INFOPLIST_FILE = SwiftNoteTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
METAL_ENABLE_DEBUG_INFO = YES;
PRODUCT_NAME = "$(TARGET_NAME)";
TEST_HOST = "$(BUNDLE_LOADER)";
};
name = Debug;
};
6640502A193E879D00428301 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/SwiftNote.app/SwiftNote";
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
"$(inherited)",
);
INFOPLIST_FILE = SwiftNoteTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
METAL_ENABLE_DEBUG_INFO = NO;
PRODUCT_NAME = "$(TARGET_NAME)";
TEST_HOST = "$(BUNDLE_LOADER)";
};
name = Release;
};
666EB8BC1941B1B200733680 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_ENTITLEMENTS = SwiftNoteTodayWidget/com.appbrewllc.SwiftNote.SwiftNoteTodayWidget.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
INFOPLIST_FILE = SwiftNoteTodayWidget/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
METAL_ENABLE_DEBUG_INFO = YES;
PRODUCT_NAME = "com.appbrewllc.SwiftNote.$(TARGET_NAME:rfc1034identifier)";
PROVISIONING_PROFILE = "";
SKIP_INSTALL = YES;
};
name = Debug;
};
666EB8BD1941B1B200733680 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_ENTITLEMENTS = SwiftNoteTodayWidget/com.appbrewllc.SwiftNote.SwiftNoteTodayWidget.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
INFOPLIST_FILE = SwiftNoteTodayWidget/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
METAL_ENABLE_DEBUG_INFO = NO;
PRODUCT_NAME = "com.appbrewllc.SwiftNote.$(TARGET_NAME:rfc1034identifier)";
PROVISIONING_PROFILE = "";
SKIP_INSTALL = YES;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
66405001193E879D00428301 /* Build configuration list for PBXProject "SwiftNote" */ = {
isa = XCConfigurationList;
buildConfigurations = (
66405023193E879D00428301 /* Debug */,
66405024193E879D00428301 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
66405025193E879D00428301 /* Build configuration list for PBXNativeTarget "SwiftNote" */ = {
isa = XCConfigurationList;
buildConfigurations = (
66405026193E879D00428301 /* Debug */,
66405027193E879D00428301 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
66405028193E879D00428301 /* Build configuration list for PBXNativeTarget "SwiftNoteTests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
66405029193E879D00428301 /* Debug */,
6640502A193E879D00428301 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
666EB8BB1941B1B200733680 /* Build configuration list for PBXNativeTarget "SwiftNoteTodayWidget" */ = {
isa = XCConfigurationList;
buildConfigurations = (
666EB8BC1941B1B200733680 /* Debug */,
666EB8BD1941B1B200733680 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
/* Begin XCVersionGroup section */
6640500D193E879D00428301 /* SwiftNote.xcdatamodeld */ = {
isa = XCVersionGroup;
children = (
6640500E193E879D00428301 /* SwiftNote.xcdatamodel */,
);
currentVersion = 6640500E193E879D00428301 /* SwiftNote.xcdatamodel */;
path = SwiftNote.xcdatamodeld;
sourceTree = "";
versionGroupType = wrapper.xcdatamodel;
};
/* End XCVersionGroup section */
};
rootObject = 66404FFE193E879D00428301 /* Project object */;
}
================================================
FILE: SwiftNoteTests/Info.plist
================================================
CFBundleDevelopmentRegion
en
CFBundleExecutable
${EXECUTABLE_NAME}
CFBundleIdentifier
com.appbrewllc.${PRODUCT_NAME:rfc1034identifier}
CFBundleInfoDictionaryVersion
6.0
CFBundleName
${PRODUCT_NAME}
CFBundlePackageType
BNDL
CFBundleShortVersionString
1.0
CFBundleSignature
????
CFBundleVersion
1
================================================
FILE: SwiftNoteTests/SwiftNoteTests.swift
================================================
//
// SwiftNoteTests.swift
// SwiftNoteTests
//
// Created by AppBrew LLC (appbrewllc.com) on 6/3/14.
// Copyright (c) 2014 Matt Lathrop. All rights reserved.
//
import XCTest
class SwiftNoteTests: XCTestCase {
override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
}
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
}
func testExample() {
// This is an example of a functional test case.
XCTAssert(true, "Pass")
}
func testPerformanceExample() {
// This is an example of a performance test case.
self.measureBlock() {
// Put the code you want to measure the time of here.
}
}
}
================================================
FILE: SwiftNoteTodayWidget/Info.plist
================================================
CFBundleDevelopmentRegion
en
CFBundleDisplayName
SwiftNoteTodayWidget
CFBundleExecutable
${EXECUTABLE_NAME}
CFBundleIdentifier
${PRODUCT_NAME}
CFBundleInfoDictionaryVersion
6.0
CFBundleName
${PRODUCT_NAME}
CFBundlePackageType
XPC!
CFBundleShortVersionString
1.0
CFBundleSignature
????
CFBundleVersion
1
NSExtension
NSExtensionMainStoryboard
MainInterface
NSExtensionPointIdentifier
com.apple.widget-extension
================================================
FILE: SwiftNoteTodayWidget/MainInterface.storyboard
================================================
================================================
FILE: SwiftNoteTodayWidget/TodayTableViewCell.swift
================================================
//
// TodayViewTableViewCell.swift
// SwiftNote
//
// Created by Matthew Lathrop on 6/14/14.
// Copyright (c) 2014 Matt Lathrop. All rights reserved.
//
import UIKit
class TodayTableViewCell: UITableViewCell {
required init(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
@IBOutlet var titleLabel: UILabel!
@IBOutlet var bodyLabel: UILabel!
func configure(#note:NoteProtocol!, indexPath:NSIndexPath!) {
self.titleLabel.text = note.title;
self.bodyLabel.text = note.body;
}
}
================================================
FILE: SwiftNoteTodayWidget/TodayViewController.swift
================================================
//
// TodayViewController.swift
// TodayWidget
//
// Created by Matthew Lathrop on 6/3/14.
// Copyright (c) 2014 Matt Lathrop. All rights reserved.
//
import CoreData
import NotificationCenter
import UIKit
class TodayViewController: UITableViewController, NCWidgetProviding, NSFetchedResultsControllerDelegate {
// MARK: variables
let kMaxCellCount = 3
let kCellHeight = 70.0
let coreDataProvider = CoreDataProvider()
var fetchedResultsController: NSFetchedResultsController {
if !(_fetchedResultsController != nil) {
// set up fetch request
var fetchRequest = NSFetchRequest()
fetchRequest.entity = NSEntityDescription.entityForName(kEntityNameNoteEntity, inManagedObjectContext: self.coreDataProvider.managedObjectContext)
// sort by last updated
var sortDescriptor = NSSortDescriptor(key: "modifiedAt", ascending: false)
fetchRequest.sortDescriptors = [sortDescriptor]
fetchRequest.fetchBatchSize = kMaxCellCount
_fetchedResultsController = NSFetchedResultsController(fetchRequest: fetchRequest, managedObjectContext: self.coreDataProvider.managedObjectContext, sectionNameKeyPath: nil, cacheName: nil)
_fetchedResultsController!.delegate = self
}
return _fetchedResultsController!
}
var _fetchedResultsController: NSFetchedResultsController? = nil
// MARK: view handling
override func viewDidLoad() {
super.viewDidLoad()
self.fetchedResultsController.performFetch(nil)
}
func widgetPerformUpdateWithCompletionHandler(completionHandler: ((NCUpdateResult) -> Void)!) {
completionHandler(NCUpdateResult.NewData)
}
func widgetMarginInsetsForProposedMarginInsets(defaultMarginInsets: UIEdgeInsets) -> UIEdgeInsets {
return UIEdgeInsets(top: 0, left: 20, bottom: 0, right: 0)
}
// MARK: Table view data source
override func numberOfSectionsInTableView(tableView: UITableView?) -> Int {
return 1
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
let sectionInfo = self.fetchedResultsController.sections?[section] as NSFetchedResultsSectionInfo
var numRows = sectionInfo.numberOfObjects
if (numRows > kMaxCellCount) {
numRows = kMaxCellCount
}
// set the content size. subtract one because i don't want the last separator showing
var height = CGFloat(numRows) * CGFloat(kCellHeight) - 1.0
self.preferredContentSize = CGSizeMake(320.0, height)
return numRows
}
override func tableView(_: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier(kReuseIdentifierTodayTableViewCell, forIndexPath: indexPath) as TodayTableViewCell
// set cell defaults
cell.backgroundColor = UIColor.clearColor()
cell.selectionStyle = .None
// configure the cell
let entity = self.fetchedResultsController.objectAtIndexPath(indexPath) as NSManagedObject
let note = Note.noteFromNoteEntity(entity)
cell.configure(note: note, indexPath: indexPath)
return cell
}
override func tableView(tableView: (UITableView!), heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
return CGFloat(kCellHeight)
}
}
================================================
FILE: SwiftNoteTodayWidget/com.appbrewllc.SwiftNote.SwiftNoteTodayWidget.entitlements
================================================
com.apple.security.application-groups
group.swiftnote.appbrewllc.com