Skip to content

Commit

Permalink
Core data finally works
Browse files Browse the repository at this point in the history
  • Loading branch information
PlaineKevin committed Dec 8, 2014
1 parent fa2463d commit 8f7d7de
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 14 deletions.
2 changes: 1 addition & 1 deletion FriendDetailsTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class FriendDetailsTableViewController: UITableViewController {
super.viewWillAppear(animated)

imageView.image = friend.image
userNameDetails.text = friend.username
userNameDetails.text = friend.userName
realNameDetails.text = friend.realName

}
Expand Down
2 changes: 1 addition & 1 deletion socialCalendar/Base.lproj/Kevin.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="0qz-hN-KCh" id="LrQ-8K-oNd">
<autoresizingMask key="autoresizingMask"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="1CX-7t-7wN">
<imageView contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="1CX-7t-7wN">
<rect key="frame" x="0.0" y="0.0" width="320" height="199"/>
<gestureRecognizers/>
<connections>
Expand Down
6 changes: 3 additions & 3 deletions socialCalendar/EditFriendsTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class EditFriendsTableViewController: UITableViewController, UIImagePickerContro

if let initialFriend = self.friend {
imageView.image = initialFriend.image
usernameTextField.text = initialFriend.username
usernameTextField.text = initialFriend.userName
realNameTextField.text = initialFriend.realName
}
}
Expand All @@ -39,7 +39,7 @@ class EditFriendsTableViewController: UITableViewController, UIImagePickerContro


@IBAction func handleImageTap(sender: UITapGestureRecognizer) {
print("i'm here");

if UIImagePickerController.isSourceTypeAvailable(.SavedPhotosAlbum) {

var imagePicker = UIImagePickerController()
Expand Down Expand Up @@ -68,7 +68,7 @@ class EditFriendsTableViewController: UITableViewController, UIImagePickerContro
// FriendManager.sharedFriendManager.friends.append(friend)
}
else {
friend.username = usernameTextField.text
friend.userName = usernameTextField.text
friend.realName = realNameTextField.text
friend.image = imageView.image
AppDelegate.sharedAppDelegate.saveContext()
Expand Down
2 changes: 1 addition & 1 deletion socialCalendar/Friend.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import CoreData

class Friend: NSManagedObject {

@NSManaged var username: String
@NSManaged var userName: String
@NSManaged var realName: String?
@NSManaged var image: UIImage?

Expand Down
2 changes: 1 addition & 1 deletion socialCalendar/FriendManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class FriendManager {
func filteredRemindersForSearchText(searchText: String) -> [Friend] {

let filteredReminders = friends.filter { (friend: Friend) -> Bool in
let stringMatch = friend.username.rangeOfString(searchText, options: .CaseInsensitiveSearch)
let stringMatch = friend.userName.rangeOfString(searchText, options: .CaseInsensitiveSearch)

return stringMatch != nil
}
Expand Down
9 changes: 3 additions & 6 deletions socialCalendar/FriendsTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class FriendsTableViewController: UITableViewController, UISearchBarDelegate, UI
fetchFriends();

// might need this here but not if we reload data somewhere else
// tableView.reloadData()
tableView.reloadData()

}

Expand All @@ -47,10 +47,6 @@ class FriendsTableViewController: UITableViewController, UISearchBarDelegate, UI

// MARK: - Table view data source

override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}

override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {

if tableView == searchDisplayController!.searchResultsTableView
Expand Down Expand Up @@ -78,10 +74,11 @@ class FriendsTableViewController: UITableViewController, UISearchBarDelegate, UI
friend = filteredFriends![indexPath.row] as Friend
}
else {
let temp = sortedFriends.first!
friend = sortedFriends[indexPath.row] as Friend
}

cell.usernameLabel.text = friend.username
cell.usernameLabel.text = friend.userName
cell.userImage?.image = friend.image

return cell
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<model userDefinedModelVersionIdentifier="" type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="6252" systemVersion="13E28" minimumToolsVersion="Xcode 4.3" macOSVersion="Automatic" iOSVersion="Automatic">
<entity name="Friend" syncable="YES">
<entity name="Friend" representedClassName="socialCalendar.Friend" syncable="YES">
<attribute name="image" optional="YES" attributeType="Transformable" syncable="YES"/>
<attribute name="realName" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="userName" optional="YES" attributeType="String" syncable="YES"/>
Expand Down

0 comments on commit 8f7d7de

Please sign in to comment.