Skip to content

Commit

Permalink
Merge pull request modo-studio#128 from dchavezlive/develop
Browse files Browse the repository at this point in the history
Fixed RestKit example and fixed iCloud stack error
  • Loading branch information
Pedro Piñera Buendía committed Feb 19, 2015
2 parents 32cf945 + aef4a08 commit 49edd48
Show file tree
Hide file tree
Showing 12 changed files with 178 additions and 94 deletions.
12 changes: 10 additions & 2 deletions example/SugarRecordExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
3DF36C881A38F5A800A73311 /* Models.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 3DF36C7E1A38F5A800A73311 /* Models.xcdatamodeld */; };
3DF36C971A39059D00A73311 /* Realm.framework in Copy Realm */ = {isa = PBXBuildFile; fileRef = 3DF36C921A39057F00A73311 /* Realm.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
3DF36C991A3905CE00A73311 /* libc++.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 3DF36C981A3905CE00A73311 /* libc++.dylib */; };
A290563A1A9634B600F47010 /* iCloudViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A29056391A9634B600F47010 /* iCloudViewController.swift */; };
A29056431A9638DA00F47010 /* ICloudModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A29056421A9638DA00F47010 /* ICloudModel.swift */; };
E14DAC441A3A0448008AC983 /* RestKitTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E14DAC431A3A0448008AC983 /* RestKitTableViewController.swift */; };
E14DAC451A3A053B008AC983 /* RestkitCDStack.swift in Sources */ = {isa = PBXBuildFile; fileRef = E1526DEE1A38A05C00BC6E1E /* RestkitCDStack.swift */; };
E1526DD11A389F3200BC6E1E /* CoreData.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E1526DD01A389F3200BC6E1E /* CoreData.framework */; };
Expand Down Expand Up @@ -100,6 +102,8 @@
3DF36C931A39057F00A73311 /* RLMSupport.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = RLMSupport.swift; path = ../../project/frameworks/realm/RLMSupport.swift; sourceTree = "<group>"; };
3DF36C981A3905CE00A73311 /* libc++.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = "libc++.dylib"; path = "usr/lib/libc++.dylib"; sourceTree = SDKROOT; };
93387547534B0073B3B4B328 /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; };
A29056391A9634B600F47010 /* iCloudViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = iCloudViewController.swift; sourceTree = "<group>"; };
A29056421A9638DA00F47010 /* ICloudModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ICloudModel.swift; sourceTree = "<group>"; };
BED8AACE3217C166E177ACA9 /* Pods.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.debug.xcconfig; path = "Pods/Target Support Files/Pods/Pods.debug.xcconfig"; sourceTree = "<group>"; };
E14DAC421A3A01BB008AC983 /* SugarRecordExample-Bridging-Header.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "SugarRecordExample-Bridging-Header.h"; path = "Supporting Files/SugarRecordExample-Bridging-Header.h"; sourceTree = "<group>"; };
E14DAC431A3A0448008AC983 /* RestKitTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RestKitTableViewController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -194,11 +198,12 @@
3DF36C781A38F5A800A73311 /* Controllers */ = {
isa = PBXGroup;
children = (
3DF36C7A1A38F5A800A73311 /* StacksTableViewController.swift */,
3DF36C791A38F5A800A73311 /* CoreDataTableViewController.swift */,
E14DAC431A3A0448008AC983 /* RestKitTableViewController.swift */,
3DF36C7A1A38F5A800A73311 /* StacksTableViewController.swift */,
3DF36C7B1A38F5A800A73311 /* StackTableViewController.swift */,
3D4754DE1A4C7C5200479D16 /* RealmTableViewController.swift */,
A29056391A9634B600F47010 /* iCloudViewController.swift */,
3DF36C7B1A38F5A800A73311 /* StackTableViewController.swift */,
);
path = Controllers;
sourceTree = "<group>";
Expand All @@ -209,6 +214,7 @@
3DF36C7D1A38F5A800A73311 /* CoreDataModel.swift */,
E197C9CC1A3F97AA000533A4 /* RestKitModel.swift */,
3DF36C7E1A38F5A800A73311 /* Models.xcdatamodeld */,
A29056421A9638DA00F47010 /* ICloudModel.swift */,
3D4754E01A4C7CD000479D16 /* RealmModel.swift */,
);
path = Models;
Expand Down Expand Up @@ -449,6 +455,7 @@
files = (
3D4754E71A4C7D3400479D16 /* RLMSupport.swift in Sources */,
3D4754ED1A4C7F5500479D16 /* SugarRecordRLMContext.swift in Sources */,
A290563A1A9634B600F47010 /* iCloudViewController.swift in Sources */,
3D4754EC1A4C7F5300479D16 /* RLMObjectMigration.swift in Sources */,
E197C9CD1A3F97AA000533A4 /* RestKitModel.swift in Sources */,
3D4754EB1A4C7F5000479D16 /* RLMObject+SugarRecord.swift in Sources */,
Expand All @@ -475,6 +482,7 @@
3DF36C841A38F5A800A73311 /* CoreDataTableViewController.swift in Sources */,
3D4754DF1A4C7C5200479D16 /* RealmTableViewController.swift in Sources */,
3DF36C881A38F5A800A73311 /* Models.xcdatamodeld in Sources */,
A29056431A9638DA00F47010 /* ICloudModel.swift in Sources */,
3D47547F1A4C460100479D16 /* SugarRecordFinder.swift in Sources */,
E1526DF71A38A05C00BC6E1E /* NSManagedObject+SugarRecord.swift in Sources */,
);
Expand Down
88 changes: 8 additions & 80 deletions example/SugarRecordExample/Resources/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6254" systemVersion="13F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="M9n-eZ-gNF">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6254" systemVersion="14D72i" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="M9n-eZ-gNF">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6247"/>
</dependencies>
Expand All @@ -13,103 +13,31 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<prototypes>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="StackCell" id="EFT-XC-5uz">
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="StackCell" textLabel="nT7-wQ-Af1" style="IBUITableViewCellStyleDefault" id="EFT-XC-5uz">
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="EFT-XC-5uz" id="tjD-Pf-2tl">
<autoresizingMask key="autoresizingMask"/>
</tableViewCellContentView>
</tableViewCell>
</prototypes>
<connections>
<outlet property="dataSource" destination="Eu1-X8-E0e" id="pyV-b2-KoB"/>
<outlet property="delegate" destination="Eu1-X8-E0e" id="SHw-Rl-HPv"/>
</connections>
</tableView>
<navigationItem key="navigationItem" title="Sugar Record" id="azx-H4-aA4"/>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="Q1h-H6-zjP" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="207" y="1067"/>
</scene>
<!--Rest Kit Table View Controller-->
<scene sceneID="nbU-Cw-qzb">
<objects>
<tableViewController storyboardIdentifier="RestKitTableViewController" id="cZb-64-1um" customClass="RestKitTableViewController" customModule="SugarRecordExample" customModuleProvider="target" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" id="p2c-ia-8hj">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<prototypes>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="ModelCell" textLabel="Pyh-da-vva" detailTextLabel="5FT-I2-I8F" style="IBUITableViewCellStyleValue1" id="mCz-bX-p4m">
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="mCz-bX-p4m" id="W44-ji-sYF">
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Title" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Pyh-da-vva">
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Title" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="nT7-wQ-Af1">
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Detail" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="5FT-I2-I8F">
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<color key="textColor" red="0.55686274509803924" green="0.55686274509803924" blue="0.57647058823529407" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</tableViewCellContentView>
</tableViewCell>
</prototypes>
<connections>
<outlet property="dataSource" destination="cZb-64-1um" id="OI6-st-fvy"/>
<outlet property="delegate" destination="cZb-64-1um" id="RB5-Fq-aXQ"/>
</connections>
</tableView>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="LwP-WL-w9o" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="845" y="1067"/>
</scene>
<!--Realm Table View Controller-->
<scene sceneID="G69-hR-yGg">
<objects>
<tableViewController storyboardIdentifier="RealmTableViewController" id="BEW-aQ-rbn" customClass="RealmTableViewController" customModule="SugarRecordExample" customModuleProvider="target" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" id="Yrb-ex-pYU">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<prototypes>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="ModelCell" textLabel="skm-Uk-kXS" detailTextLabel="xAl-x6-EtG" style="IBUITableViewCellStyleValue1" id="RrG-WB-wVP">
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="RrG-WB-wVP" id="DIc-OD-fDz">
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Title" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="skm-Uk-kXS">
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Detail" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="xAl-x6-EtG">
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<color key="textColor" red="0.5568627451" green="0.5568627451" blue="0.57647058819999997" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</tableViewCellContentView>
</tableViewCell>
</prototypes>
<connections>
<outlet property="dataSource" destination="BEW-aQ-rbn" id="ZX3-kl-FSg"/>
<outlet property="delegate" destination="BEW-aQ-rbn" id="G1z-ZJ-Pdl"/>
<outlet property="dataSource" destination="Eu1-X8-E0e" id="pyV-b2-KoB"/>
<outlet property="delegate" destination="Eu1-X8-E0e" id="SHw-Rl-HPv"/>
</connections>
</tableView>
<navigationItem key="navigationItem" title="Sugar Record" id="azx-H4-aA4"/>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="eis-vU-nfp" userLabel="First Responder" sceneMemberID="firstResponder"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="Q1h-H6-zjP" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1477" y="1067"/>
<point key="canvasLocation" x="207" y="1067"/>
</scene>
<!--Navigation Controller-->
<scene sceneID="0NB-L6-J9t">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class RealmTableViewController: StackTableViewController
override func viewDidLoad() {
super.viewDidLoad()
self.title = "Realm"
self.tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: self.cellIdentifier())
self.stack = DefaultREALMStack(stackName: "Realm", stackDescription: "")
SugarRecord.addStack(self.stack!)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,24 @@

import UIKit

class RestKitTableViewController: CoreDataTableViewController {
class RestKitTableViewController: StackTableViewController {

//MARK: - Attributes

var data: SugarRecordResults?
internal let model: NSManagedObjectModel = {
let modelPath: NSString = NSBundle.mainBundle().pathForResource("Models", ofType: "momd")!
let model: NSManagedObjectModel = NSManagedObjectModel(contentsOfURL: NSURL(fileURLWithPath: modelPath)!)!
return model
}()

//MARK: - Viewcontroller Lifecycle

typealias T = NSManagedObject
override func viewDidLoad() {
super.viewDidLoad()
self.title = "RestKit"
self.tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: self.cellIdentifier())
self.stack = DefaultCDStack(databaseName: "RestKit.sqlite", model: self.model, automigrating: true)
SugarRecord.addStack(self.stack!)
}
Expand All @@ -42,15 +52,29 @@ class RestKitTableViewController: CoreDataTableViewController {
self.data = RestKitModel.all().sorted(by: "date", ascending: false).find()
}

override func dataCount() -> Int {
if (data == nil) { return 0 }
else { return data!.count }
}


//MARK: - Cell

override func configureCell(cell: UITableViewCell, indexPath: NSIndexPath) {
let formatter = NSDateFormatter()
formatter.dateFormat = "MMMM d yyyy - HH:mm:ss"
let model = self.data![indexPath.row] as RestKitModel
cell.textLabel!.text = model.name
cell.detailTextLabel!.text = formatter.stringFromDate(model.date)
cell.textLabel?.text = model.name
cell.detailTextLabel?.text = formatter.stringFromDate(model.date)
}

override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
if (editingStyle == .Delete) {
let model = self.data![indexPath.row] as RestKitModel
model.beginWriting().delete().endWriting()
self.fetchData()
tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade)
}
}

override func cellIdentifier() -> String {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class StackTableViewController: UITableViewController
}

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier(self.cellIdentifier(), forIndexPath: indexPath) as UITableViewCell
let cell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: cellIdentifier())
self.configureCell(cell, indexPath: indexPath)
return cell
}
Expand Down
Loading

0 comments on commit 49edd48

Please sign in to comment.