nearby places swift 2 error - swift2

I work on a ios application that requires to use nearby places api from google. It worked very well with swift but now , when i updated my xcode to xcode 7 and it changed from swift to swift 2 it doesn't work anymore. I am stuck with this , any help will be apreciated .
Here is the request for the api :
func fetchPlacesNearCoordinate(coordinate: CLLocationCoordinate2D, radius: Double, name : String){
var urlString = "https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=\(44.942149),\(26.02453)&radius=\(radius)&types=food"
urlString += "&key=\(apiServerKey)"
urlString = urlString.stringByAddingPercentEscapesUsingEncoding(NSUTF8StringEncoding)!
if placesTask.taskIdentifier > 0 && placesTask.state == .Running {
placesTask.cancel()
}
UIApplication.sharedApplication().networkActivityIndicatorVisible = true
do{
//******************Here's the line that displays error
placesTask = session.dataTaskWithURL(NSURL(string: urlString)!) {
(data, response, error) -> Void in
UIApplication.sharedApplication().networkActivityIndicatorVisible = false
//var placesArray = [GooglePlace]()
do {
if let json = try NSJSONSerialization.JSONObjectWithData(data!, options:[]) as? NSDictionary {
if let results = json["results"] as? NSArray {
for rawPlace:AnyObject in results {
print(rawPlace)
var placename = ""
if let name = rawPlace["name"] as? NSString {
placename = name as String
}
}
}
}
} catch {
//handle error
}
/*dispatch_async(dispatch_get_main_queue()) {
completion(placesArray)
}*/
}
}catch{
}
placesTask.resume()
}
And the errors i get :
2015-10-02 16:57:54.586 QR Code[4331:67414] -[NSURLSessionDataTask taskIdentifier]: unrecognized selector sent to instance 0x7fe791c3b840
2015-10-02 16:57:54.591 QR Code[4331:67414] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSURLSessionDataTask taskIdentifier]: unrecognized selector sent to instance 0x7fe791c3b840'
*** First throw call stack:(
0 CoreFoundation 0x0000000111a8ef65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x0000000111506deb objc_exception_throw + 48
2 CoreFoundation 0x0000000111a9758d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x00000001119e4f7a ___forwarding___ + 970
4 CoreFoundation 0x00000001119e4b28 _CF_forwarding_prep_0 + 120
5 QR Code 0x000000010f57b3ff _TFC7QR_Code17MapViewController25fetchPlacesNearCoordinatefS0_FTVSC22CLLocationCoordinate2D6radiusSd4nameSS_T_ + 1215
6 QR Code 0x000000010f57bfd3 _TFC7QR_Code17MapViewController11viewDidLoadfS0_FT_T_ + 1555
7 QR Code 0x000000010f57c552 _TToFC7QR_Code17MapViewController11viewDidLoadfS0_FT_T_ + 34
8 UIKit 0x00000001122ae931 -[UIViewController loadViewIfRequired] + 1344
9 UIKit 0x00000001122b4923 -[UIViewController __viewWillAppear:] + 120
10 UIKit 0x00000001122e418a -[UINavigationController _startCustomTransition:] + 1177
11 UIKit 0x00000001122f37c7 -[UINavigationController _startDeferredTransitionIfNeeded:] + 712
12 UIKit 0x00000001122f467d -[UINavigationController __viewWillLayoutSubviews] + 57
13 UIKit 0x000000011248c63d -[UILayoutContainerView layoutSubviews] + 248
14 UIKit 0x00000001121d411c -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 710
15 QuartzCore 0x000000010fe7536a -[CALayer layoutSublayers] + 146
16 QuartzCore 0x000000010fe69bd0 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366
17 QuartzCore 0x000000010fe69a4e _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
18 QuartzCore 0x000000010fe5e1d5 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 277
19 QuartzCore 0x000000010fe8b9f0 _ZN2CA11Transaction6commitEv + 508
20 UIKit 0x000000011211e1b6 _UIApplicationHandleEventQueue + 7183
21 CoreFoundation 0x00000001119bb0a1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
22 CoreFoundation 0x00000001119b0fcc __CFRunLoopDoSources0 + 556
23 CoreFoundation 0x00000001119b0483 __CFRunLoopRun + 867
24 CoreFoundation 0x00000001119afe98 CFRunLoopRunSpecific + 488
25 GraphicsServices 0x0000000115770ad2 GSEventRunModal + 161
26 UIKit 0x0000000112123676 UIApplicationMain + 171
27 QR Code 0x000000010f5782bd main + 109
28 libdyld.dylib 0x0000000113dd192d start + 1)
libc++abi.dylib: terminating with uncaught exception of type NSException

Please do not call the Places API Web Services directly from a mobile device - it opens up the potential for external parties to steal your API key from your application. Please follow the Proxy Server pattern laid out in this tutorial by Ray Wenderlich's team.

Related

Cannot InsertText with Message App Extension

I'm creating a Message App Extension in Xamarin and am getting a NSException error when trying to InsertText from the MessagesViewController. I do not see error messages when building, just when this InsertText code is executed. Appreciate your help/expertise.
InsertText code
public void InsertMessage(string message)
{
ActiveConversation.InsertText(message, (err) => {
if (err != null)
{
Console.WriteLine("ERROR: " + err.ToString());
}
});
Console.WriteLine("Inserted text");
}
Console Error Message
2022-10-19 14:17:02.869031-0700 MobileSMS[40085:1435095] -[CKIMDaemonController preWarm]: unrecognized selector sent to instance 0x60000326aa80
2022-10-19 14:17:02.871325-0700 MobileSMS[40085:1435095] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CKIMDaemonController preWarm]: unrecognized selector sent to instance 0x60000326aa80'
*** First throw call stack:
(
0 CoreFoundation 0x00007ff800427378 __exceptionPreprocess + 242
1 libobjc.A.dylib 0x00007ff80004dbaf objc_exception_throw + 48
2 CoreFoundation 0x00007ff800436588 +[NSObject(NSObject) instanceMethodSignatureForSelector:] + 0
3 CoreFoundation 0x00007ff80042b83d ___forwarding___ + 1431
4 CoreFoundation 0x00007ff80042db38 _CF_forwarding_prep_0 + 120
5 IMCore 0x00007ff810903f11 IMCoreSimulatedEnvironmentEnabled + 155997
6 ChatKit 0x00000001098998c0 __46-[CKChatInputController _startEditingPayload:]_block_invoke + 591
7 ChatKit 0x00000001099f25ae __69+[CKComposition compositionWithShelfPluginPayload:completionHandler:]_block_invoke + 115
8 libdispatch.dylib 0x00007ff80013b7fb _dispatch_call_block_and_release + 12
9 libdispatch.dylib 0x00007ff80013ca3a _dispatch_client_callout + 8
10 libdispatch.dylib 0x00007ff80014c32c _dispatch_main_queue_drain + 1338
11 libdispatch.dylib 0x00007ff80014bde4 _dispatch_main_queue_callback_4CF + 31
12 CoreFoundation 0x00007ff8003869f7 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
13 CoreFoundation 0x00007ff8003813c6 __CFRunLoopRun + 2482
14 CoreFoundation 0x00007ff800380637 CFRunLoopRunSpecific + 560
15 GraphicsServices 0x00007ff809c0f28a GSEventRunModal + 139
16 UIKitCore 0x00000001145c4425 -[UIApplication _run] + 994
17 UIKitCore 0x00000001145c9301 UIApplicationMain + 123
18 MobileSMS 0x0000000106198220 MobileSMS + 131616
19 dyld 0x00000001063ed2bf start_sim + 10
20 ??? 0x000000010d42a52e 0x0 + 4517438766
)
libc++abi: terminating with uncaught exception of type NSException
The error seems to be related to using the iPhone simulator, as I got it to work on a connected device without any errors.

Error when running my ios sumilator : Exception '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]

I have just done some configs in Xcode and appdelegate.m for RNFirebase, RNFBSDK, and google Sign-In. After following al the steps I have an error when running my ios simulator with react-native run ios.
I have tried to tweak the AppDelegate.m, I deleted my build folders and recompiled
My AppDelegate.m file looks like this
#import "AppDelegate.h"
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import <ReactNativeNavigation/ReactNativeNavigation.h>
#import <RNGoogleSignin/RNGoogleSignin.h>
#import <Firebase.h>
#import <FBSDKCoreKit/FBSDKCoreKit.h>
#implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Firebase configurations
[FIRApp configure];
// Facebook SDK
[[FBSDKApplicationDelegate sharedInstance] application:application
didFinishLaunchingWithOptions:launchOptions];
NSURL *jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:#"index" fallbackResource:nil];
[ReactNativeNavigation bootstrap:jsCodeLocation launchOptions:launchOptions];
return YES;
}
// RNGoogleSignin.h -> https://github.com/react-native-community/react-native-google-signin/blob/master/docs/ios-guide.md#modify-your-app-to-respond-to-the-url-scheme-optional
- (BOOL)application:(UIApplication *)application openURL:(nonnull NSURL *)url options:(nonnull NSDictionary<NSString *,id> *)options {
return [RNGoogleSignin application:application
openURL:url
sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey]
annotation:options[UIApplicationOpenURLOptionsAnnotationKey]];
}
// FACEBOOK SDK
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
BOOL handled = [[FBSDKApplicationDelegate sharedInstance] application:application
openURL:url
sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey]
annotation:options[UIApplicationOpenURLOptionsAnnotationKey]
];
// Add any custom logic here.
return handled;
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
[FBSDKAppEvents activateApp];
}
- (BOOL)application:(UIApplication *)app
openURL:(NSURL *)url
options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
{
if ([[FBSDKApplicationDelegate sharedInstance] application:app openURL:url options:options]) {
return YES;
}
if ([RCTLinkingManager application:app openURL:url options:options]) {
return YES;
}
return NO;
}
#end
this is the entire error popping on the simulator screen instead of the app launching:
Exception '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0]' was thrown while invoking getImageForFont on target RNVectorIconsManager with params (
Entypo,
"\Uf241",
30,
4278190080,
35
)
callstack: (
0 CoreFoundation 0x0000000111f926fb __exceptionPreprocess + 331
1 libobjc.A.dylib 0x000000011097eac5 objc_exception_throw + 48
2 CoreFoundation 0x0000000111ee0ddc _CFThrowFormattedException + 194
3 CoreFoundation 0x0000000111ffec31 -[__NSPlaceholderDictionary initWithObjects:forKeys:count:] + 321
4 CoreFoundation 0x0000000111f8e3db +[NSDictionary dictionaryWithObjects:forKeys:count:] + 59
5 madilist_app 0x000000010d8339bf -[RNVectorIconsManager createAndSaveGlyphImage:withFont:withFilePath:withColor:] + 415
6 madilist_app 0x000000010d833d68 -[RNVectorIconsManager getImageForFont:withGlyph:withFontSize:withColor:callback:] + 360
7 CoreFoundation 0x0000000111f994cc __invoking___ + 140
8 CoreFoundation 0x0000000111f96a45 -[NSInvocation invoke] + 325
9 CoreFoundation 0x0000000111f96e96 -[NSInvocation invokeWithTarget:] + 54
10 madilist_app 0x000000010d528fba -[RCTModuleMethod invokeWithBridge:module:arguments:] + 2810
11 madilist_app 0x000000010d5db096 _ZN8facebook5reactL11invokeInnerEP9RCTBridgeP13RCTModuleDatajRKN5folly7dynamicE + 790
12 madilist_app 0x000000010d5daba3 _ZZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEiENK3$_0clEv + 131
13 madilist_app 0x000000010d5dab19 ___ZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEi_block_invoke + 25
14 libdispatch.dylib 0x000000011497accf _dispatch_call_block_and_release + 12
15 libdispatch.dylib 0x000000011497bd02 _dispatch_client_callout + 8
16 libdispatch.dylib 0x0000000114982720 _dispatch_lane_serial_drain + 705
17 libdispatch.dylib 0x0000000114983261 _dispatch_lane_invoke + 398
18 libdispatch.dylib 0x000000011498bfcb _dispatch_workloop_worker_thread + 645
19 libsystem_pthread.dylib 0x0000000114d5d611 _pthread_wqthread + 421
20 libsystem_pthread.dylib 0x0000000114d5d3fd start_wqthread + 13
)
RCTFatal
facebook::react::invokeInner(RCTBridge*, RCTModuleData*, unsigned int, folly::dynamic const&)
facebook::react::RCTNativeModule::invoke(unsigned int, folly::dynamic&&, int)::$_0::operator()() const
invocation function for block in facebook::react::RCTNativeModule::invoke(unsigned int, folly::dynamic&&, int)
_dispatch_call_block_and_release
_dispatch_client_callout
_dispatch_lane_serial_drain
_dispatch_lane_invoke
_dispatch_workloop_worker_thread
_pthread_wqthread
start_wqthread

Trying build a note app, Xcode 8, get this error

I've been following a tutorial (outdated as it says) and I'm trying to build my first note app. Unfortunately it is terminated before it even runs. Any help would be much appreciated. This is the code and at the end the crash-report. Cheers !
import UIKit
import CoreData
#UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
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 invalidate graphics rendering callbacks. 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 active 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()
}
// MARK: - Core Data stack
lazy var persistentContainer: NSPersistentContainer = {
/*
The persistent container for the application. This implementation
creates and returns a container, having loaded the store for the
application to it. This property is optional since there are legitimate
error conditions that could cause the creation of the store to fail.
*/
let container = NSPersistentContainer(name: "ToDo")
container.loadPersistentStores(completionHandler: { (storeDescription, error) in
if let error = error as NSError? {
// Replace this implementation with code to handle the error appropriately.
// fatalError() 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 parent directory does not exist, cannot be created, or disallows writing.
* The persistent store is not accessible, due to permissions or data protection when the device is locked.
* The device is out of space.
* The store could not be migrated to the current model version.
Check the error message to determine what the actual problem was.
*/
fatalError("Unresolved error \(error), \(error.userInfo)")
}
})
return container
}()
// MARK: - Core Data Saving support
func saveContext () {
let context = persistentContainer.viewContext
if context.hasChanges {
do {
try context.save()
} catch {
// Replace this implementation with code to handle the error appropriately.
// fatalError() 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.
let nserror = error as NSError
fatalError("Unresolved error \(nserror), \(nserror.userInfo)")
}
}
}
}
This is the crash report I get
2017-05-14 21:04:58.079 ToDo[17123:3603269] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'must pass a class of kind UITableViewCell'
*** First throw call stack:
(
0 CoreFoundation 0x000000010fcbdb0b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010cb39141 objc_exception_throw + 48
2 CoreFoundation 0x000000010fd26625 +[NSException raise:format:] + 197
3 UIKit 0x000000010d57fdde -[UITableView registerClass:forCellReuseIdentifier:] + 284
4 ToDo 0x000000010c5597db _TFC4ToDo14ViewController11viewDidLoadfT_T_ + 571
5 ToDo 0x000000010c5598e2 _TToFC4ToDo14ViewController11viewDidLoadfT_T_ + 34
6 UIKit 0x000000010d5c2cca -[UIViewController loadViewIfRequired] + 1235
7 UIKit 0x000000010d601b1c -[UINavigationController _layoutViewController:] + 56
8 UIKit 0x000000010d6023fa -[UINavigationController _updateScrollViewFromViewController:toViewController:] + 466
9 UIKit 0x000000010d60256b -[UINavigationController _startTransition:fromViewController:toViewController:] + 127
10 UIKit 0x000000010d6036b3 -[UINavigationController _startDeferredTransitionIfNeeded:] + 843
11 UIKit 0x000000010d6047f1 -[UINavigationController __viewWillLayoutSubviews] + 58
12 UIKit 0x000000010d7f62bc -[UILayoutContainerView layoutSubviews] + 231
13 UIKit 0x000000010d4e320b -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1268
14 QuartzCore 0x0000000112aa5904 -[CALayer layoutSublayers] + 146
15 QuartzCore 0x0000000112a99526 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 370
16 QuartzCore 0x0000000112a993a0 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
17 QuartzCore 0x0000000112a28e92 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 294
18 QuartzCore 0x0000000112a55130 _ZN2CA11Transaction6commitEv + 468
19 QuartzCore 0x0000000112a55b37 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 115
20 CoreFoundation 0x000000010fc63717 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
21 CoreFoundation 0x000000010fc63687 __CFRunLoopDoObservers + 391
22 CoreFoundation 0x000000010fc48038 CFRunLoopRunSpecific + 440
23 UIKit 0x000000010d41a02f -[UIApplication _run] + 468
24 UIKit 0x000000010d4200d4 UIApplicationMain + 159
25 ToDo 0x000000010c55d077 main + 55
26 libdyld.dylib 0x0000000110c5d65d start + 1
27 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)

Swift + Parse: 'Can't use nil for keys or values on PFObject. Use NSNull for values.'

So I have a Swift application that I am working on (in Xcode 7.3).
It uses Parse and in it I have a function that is generating the error message stated in the title.
The code appears as follows;
#IBAction func callUber(sender: AnyObject) {
let riderRequest = PFObject(className:"riderRequest")
riderRequest["username"] = PFUser.currentUser()?.username
riderRequest["location "] = PFGeoPoint(latitude:latitude, longitude:longitude)
riderRequest.saveInBackgroundWithBlock {
(success: Bool, error: NSError?) -> Void in
if (success) {
self.callUberButton.setTitle("Cancel Uber", forState: UIControlState.Normal)
} else {
let alert = UIAlertController(title: "Could not call Uber", message: "Please try again", preferredStyle: UIAlertControllerStyle.Alert)
alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: nil))
self.presentViewController(alert, animated: true, completion: nil)
}
}
}
Now somewhere in this code nil is being applied to a value, and this causes the error message (or so I think). I have been looking around on SO for solutions to this problem, however I could not find any similar threads for this error message and Swift, only Objective-C.
I'm guessing that I have to introduce some sort of error handling or check where I make sure that the value of the object is not nil, however I cant seem to figure out where, or how to apply this.
The error is only triggered when I press the "callUber" button, and the full output from the debug console follows below.
2016-04-15 12:21:01.900 ParseStarterProject-Swift[8781:2591354] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Can't use nil for keys or values on PFObject. Use NSNull for values.'
*** First throw call stack:
(
0 CoreFoundation 0x000000010ca98d85 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010eca0deb objc_exception_throw + 48
2 CoreFoundation 0x000000010ca98cbd +[NSException raise:format:] + 205
3 ParseStarterProject-Swift 0x000000010c1042a8 -[PFObject(Private) _setObject:forKey:onlyIfDifferent:] + 122
4 ParseStarterProject-Swift 0x000000010c107d01 -[PFObject setObject:forKey:] + 53
5 ParseStarterProject-Swift 0x000000010c107d46 -[PFObject setObject:forKeyedSubscript:] + 50
6 ParseStarterProject-Swift 0x000000010c0c847f _TFC25ParseStarterProject_Swift19RiderViewController8callUberfPs9AnyObject_T_ + 671
7 ParseStarterProject-Swift 0x000000010c0c89d6 _TToFC25ParseStarterProject_Swift19RiderViewController8callUberfPs9AnyObject_T_ + 54
8 UIKit 0x000000010d726a8d -[UIApplication sendAction:to:from:forEvent:] + 92
9 UIKit 0x000000010d899e67 -[UIControl sendAction:to:forEvent:] + 67
10 UIKit 0x000000010d89a143 -[UIControl _sendActionsForEvents:withEvent:] + 327
11 UIKit 0x000000010d899263 -[UIControl touchesEnded:withEvent:] + 601
12 UIKit 0x000000010d79999f -[UIWindow _sendTouchesForEvent:] + 835
13 UIKit 0x000000010d79a6d4 -[UIWindow sendEvent:] + 865
14 UIKit 0x000000010d745dc6 -[UIApplication sendEvent:] + 263
15 UIKit 0x000000011dfe0b15 -[UIApplicationAccessibility sendEvent:] + 77
16 UIKit 0x000000010d71f553 _UIApplicationHandleEventQueue + 6660
17 CoreFoundation 0x000000010c9be301 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
18 CoreFoundation 0x000000010c9b422c __CFRunLoopDoSources0 + 556
19 CoreFoundation 0x000000010c9b36e3 __CFRunLoopRun + 867
20 CoreFoundation 0x000000010c9b30f8 CFRunLoopRunSpecific + 488
21 GraphicsServices 0x0000000111eb0ad2 GSEventRunModal + 161
22 UIKit 0x000000010d724f09 UIApplicationMain + 171
23 ParseStarterProject-Swift 0x000000010c0cc712 main + 114
24 libdyld.dylib 0x000000010f7a792d start + 1
25 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
A couple of things that may be the issue:
Double check your class name is "riderRequest", I think "RiderRequest" could possibly be the actual name.
Second is to check all your key names are correct by going to the parse dashboard and having a look at your class
Last thing is to confirm that all your values for things like username and latitude and longitude are not nil before setting them.
Maybe try:
if let username = PFUser.currentUser()?.username && latitude != nil && longitude != nil {
riderRequest.setObject(username, forKey: "username")
riderRequest.setObject(PFGeoPoint(latitude: latitude, longitude: longitude), forKey: "location")
//then run the rest of the code as you have been
}

IOS Simulator keeps crashing?

Whenever I try to Run the IOS Simulator, it keeps crashing. I work on Xcode 5.0.2. On the main.m file it says
Thread 1:SIGABRT. Heres is the line where the SIGABRT appeared.
return UIApplicationMain(argc, argv, nil, NSStringFromClass([xyzAppDelegate class]));
heres what was going on in the main.m
#import <UIKit/UIKit.h>
#import "xyzAppDelegate.h"
int main(int argc, char * argv[])
{
#autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([xyzAppDelegate class]));
}
}
xyzAppDelegate.h
#import <UIKit/UIKit.h>
#interface xyzAppDelegate : UIResponder <UIApplicationDelegate>
#property (strong, nonatomic) UIWindow *window;
#end
xyzAppDelegate.m
#import "xyzAppDelegate.h"
#implementation xyzAppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions: (NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application
{
}
- (void)applicationDidEnterBackground:(UIApplication *)application
{
}
- (void)applicationWillEnterForeground:(UIApplication *)application
{
}
- (void)applicationDidBecomeActive:(UIApplication *)application
{
}
- (void)applicationWillTerminate:(UIApplication *)application
{
}
#end
Here is what it shows on the debug area
2014-02-13 00:06:47.933 ToDoList[707:70b] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </Users/garibaldi/Library/Application Support/iPhone Simulator/7.0.3/Applications/8B1ABBAB-D173-4A8E-80AC-8DEA44C5EDE8/ToDoList.app> (loaded)' with name 'Main''
*** First throw call stack:
(
0 CoreFoundation 0x0174c5e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x014bb8b6 objc_exception_throw + 44
2 CoreFoundation 0x0174c3bb +[NSException raise:format:] + 139
3 UIKit 0x004ca39c -[UINib instantiateWithOwner:options:] + 951
4 UIKit 0x004cc2fb -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 165
5 UIKit 0x002293bb -[UIApplication _loadMainNibFileNamed:bundle:] + 58
6 UIKit 0x002296e9 -[UIApplication _loadMainInterfaceFile] + 245
7 UIKit 0x0022828f -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 543
8 UIKit 0x0023c87c -[UIApplication handleEvent:withNewEvent:] + 3447
9 UIKit 0x0023cde9 -[UIApplication sendEvent:] + 85
10 UIKit 0x0022a025 _UIApplicationHandleEvent + 736
11 GraphicsServices 0x036df2f6 _PurpleEventCallback + 776
12 GraphicsServices 0x036dee01 PurpleEventCallback + 46
13 CoreFoundation 0x016c7d65 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
14 CoreFoundation 0x016c7a9b __CFRunLoopDoSource1 + 523
15 CoreFoundation 0x016f277c __CFRunLoopRun + 2156
16 CoreFoundation 0x016f1ac3 CFRunLoopRunSpecific + 467
17 CoreFoundation 0x016f18db CFRunLoopRunInMode + 123
18 UIKit 0x00227add -[UIApplication _run] + 840
19 UIKit 0x00229d3b UIApplicationMain + 1225
20 ToDoList 0x0000219d main + 141
21 libdyld.dylib 0x01d7670d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
I tried following Apple's First Tutorial. Sorry if I'm not clear enough, I'm still kinda new here.
Try resetting the simulator.
I'm sorry I cannot yet upload images, but:
(If simulator is not running)
In XCode, go to XCode menu (one left of 'File') on top, 'Open Developer Tool' > 'iOS Simulator'.
In the simulator, click on the 'iOS Simulator menu' > 'Rest Content And Settings...'
Try resetting the simulator (as in #bauerMusic's answer) and then restart your Mac. That consistently fixes a similar issue I have.

Resources