From 7f5afd95fde89cf5250a2eab188f54c1451fff3f Mon Sep 17 00:00:00 2001 From: Okechi Date: Thu, 4 Feb 2016 02:52:17 -0500 Subject: [PATCH] Added restriction to adding a friend already in friend list, added camera and library access to settings menu to change user photo, will add parse connections to change photo and add profile image queries tomorrow or this weekend 2/05/16-2/07/16 --- GetHip.xcodeproj/project.pbxproj | 7 ++++ GetHip/AppDelegate.swift | 49 ++++++++++++++++++++++- GetHip/FriendRequestViewController.swift | 5 ++- GetHip/FriendsListViewController.swift | 10 +++-- GetHip/Main.storyboard | 4 +- GetHip/PendingRequestViewController.swift | 11 ++++- GetHip/SettingsDetailViewWrapper.swift | 40 ++++++++++++++++-- GetHip/ViewController.swift | 8 +++- 8 files changed, 118 insertions(+), 16 deletions(-) diff --git a/GetHip.xcodeproj/project.pbxproj b/GetHip.xcodeproj/project.pbxproj index dee6ce5..99d4e54 100644 --- a/GetHip.xcodeproj/project.pbxproj +++ b/GetHip.xcodeproj/project.pbxproj @@ -672,6 +672,7 @@ TargetAttributes = { 3E1BDA4B1C37111D00EE3B84 = { CreatedOnToolsVersion = 6.3.2; + DevelopmentTeam = 24WJ762CQL; }; 3E1BDA631C37111D00EE3B84 = { CreatedOnToolsVersion = 6.3.2; @@ -922,6 +923,8 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; + CODE_SIGN_IDENTITY = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", /Users/okechi/Documents/FacebookSDK, @@ -935,6 +938,7 @@ "$(SDKROOT)/usr/lib/system", ); PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE = ""; SWIFT_OBJC_BRIDGING_HEADER = "$PROJECT_NAME/Bridging-Header.h"; }; name = Debug; @@ -943,6 +947,8 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; + CODE_SIGN_IDENTITY = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", /Users/okechi/Documents/FacebookSDK, @@ -956,6 +962,7 @@ "$(SDKROOT)/usr/lib/system", ); PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE = ""; SWIFT_OBJC_BRIDGING_HEADER = "$PROJECT_NAME/Bridging-Header.h"; }; name = Release; diff --git a/GetHip/AppDelegate.swift b/GetHip/AppDelegate.swift index 13d81a4..908b736 100644 --- a/GetHip/AppDelegate.swift +++ b/GetHip/AppDelegate.swift @@ -15,11 +15,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate , CLLocationManagerDelegat var window: UIWindow? // var locationStarted = false - // var locationManager: CLLocationManager = CLLocationManager() + var locationManager: CLLocationManager! // var app = UIApplication.sharedApplication() func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { - + application.registerForRemoteNotifications() //create new CLLocaationManager /*var locationStarted = false locationManager.delegate = self*/ @@ -36,6 +36,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate , CLLocationManagerDelegat let paths = NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomainMask.UserDomainMask, true) print(paths[0])*/ + startSignificantChangeUpdates() return true } @@ -77,6 +78,50 @@ class AppDelegate: UIResponder, UIApplicationDelegate , CLLocationManagerDelegat self.saveContext() } + //Core Location + func startSignificantChangeUpdates(){ + + if(locationManager == nil){ + locationManager = CLLocationManager() + } + + locationManager.delegate = self + locationManager.startMonitoringSignificantLocationChanges() + } + + func locationManager(manager: CLLocationManager!, didUpdateLocations locations: [AnyObject]!) { + var location: CLLocation! = locations.last as! CLLocation + var geo:PFGeoPoint! = PFGeoPoint(location: location) + + var query = PFQuery(className: "_User") + var currentUser = PFUser.currentUser() + + query.whereKey("username", equalTo: (currentUser?.username as String!)) + + query.getFirstObjectInBackgroundWithBlock({ + (object: PFObject?, error: NSError?) -> Void in + + if(error == nil){ + object?.setObject(geo, forKey: "location") + object?.saveInBackground() + } + }) + } + + /* + func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) { + NSLog("Did register for remote notifications with device token (%@)", deviceToken) + } + + func application(application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: NSError) { + NSLog("Did Fail to register for remote notifications") + NSLog("%@, %@", error, error.localizedDescription) + } + + func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]) { + + }*/ + // MARK: - Core Data stack diff --git a/GetHip/FriendRequestViewController.swift b/GetHip/FriendRequestViewController.swift index 12e7b1e..a0e9dc8 100644 --- a/GetHip/FriendRequestViewController.swift +++ b/GetHip/FriendRequestViewController.swift @@ -133,12 +133,12 @@ extension FriendRequestViewController: UITextFieldDelegate{ self.searchedUsername = searchBar.text var inFriendsList: Bool = false - /*for name in self.frnds{ + for name in self.frnds{ if name == self.searchedUsername{ inFriendsList = true break } - }*/ + } if(inFriendsList == false){ var query = PFQuery(className: "_User") query.whereKey("username", equalTo: searchedUsername) @@ -157,6 +157,7 @@ extension FriendRequestViewController: UITextFieldDelegate{ }) }else{ let alert = UIAlertController(title: "Already Friends", message: "You are already friends with this user!", preferredStyle: .Alert) + alert.addAction(UIAlertAction(title: "OK", style: .Default, handler:{(action: UIAlertAction!) in alert.dismissViewControllerAnimated(true, completion: nil)})) self.presentViewController(alert, animated: true, completion: nil) } diff --git a/GetHip/FriendsListViewController.swift b/GetHip/FriendsListViewController.swift index 122c409..bbf9dca 100644 --- a/GetHip/FriendsListViewController.swift +++ b/GetHip/FriendsListViewController.swift @@ -141,10 +141,12 @@ class FriendsListViewController: UIViewController, UITableViewDelegate, UITableV } if segue.identifier == "FriendRequestSegue" { - /* var frndNames: [String] = [] + var frndNames: [String] = [] + println(self.friends.count) for i in 0...self.friends.count-1{ - var str:String! = self.friends[i].displayName as String! - frndNames.append(str) + var frends: FriendData! = self.friends[i] as! FriendData + println(frends.displayName!) + frndNames.append(frends.displayName!) } /*for name in self.friends{ @@ -154,7 +156,7 @@ class FriendsListViewController: UIViewController, UITableViewDelegate, UITableV }*/ let vc: FriendRequestViewController = (segue.destinationViewController as? FriendRequestViewController)! - vc.setData(frndNames)*/ + vc.setData(frndNames) } } diff --git a/GetHip/Main.storyboard b/GetHip/Main.storyboard index 816158e..b728af1 100644 --- a/GetHip/Main.storyboard +++ b/GetHip/Main.storyboard @@ -95,7 +95,7 @@