Ich lerne iOS Dev und habe eine Crashing MapKit App. Benötigen Sie Hilfe bei der Verständnis dieses Crashprotokolls

StackOverflow https://stackoverflow.com/questions/6811085

Frage

Ich arbeite an der App mit dem Namen WHereami aus dem "BNR Guide to iOS -Programmierung" Kapitel 5. Ich habe die App funktioniert und lasse sie auf meinem Handy, um der Frau und Familie zu zeigen, dass ich Sachen lerne. Es zeigt jedoch ein regelmäßiges Absturzverhalten. Hier ist was passiert ....

Wenn Sie die App zum ersten Mal öffnen und sie ausführen, funktioniert es in Ordnung, wenn Sie nach Hause schlagen und sie dann innerhalb von nur wenigen Minuten wieder öffnen, ist es in Ordnung. Wenn Sie es im Hintergrund lassen ) Später stürzt es ab. Sie können es dann wieder eröffnen und es funktioniert gut, aber das Muster wiederholt sich.

Ich habe meinen gesamten Code mit dem Buch doppelt überprüft und auf der Seite Errata gesucht, kann aber nicht herausfinden, was falsch sein könnte. Der Xcode -Organizer zeigt Protokolle für alle Abstürze an, aber ich weiß noch nicht, wie ich das lesen soll. Ich habe mich gefragt, ob es sich nur um eine Lernprojekt -App handelt, die nicht für eine echte Verwendung gedacht ist, vielleicht etwas fehlt, das es Multitasking/Hintergrund/Wiedereröffnung macht ??? korrekt? Ich verwende Xcode 4.1 auf Lion mit iPhone 4 mit iOS 4.3.4. Ich wäre dankbar für jede Unterstützung, die jeder anbieten kann.

Hier ist, was ich denke, der relevante Teil des Crash -Protokolls:

Incident Identifier: 352B538C-75BB-4BDF-9C2B-EC9613CE1B44
CrashReporter Key:   5896ed7851b999169919cab30c69940f74ed6b0c
Hardware Model:      iPhone3,1
Process:         WhereAmI [775]
Path:            /var/mobile/Applications/DB57A854-01F8-460F-B8CD-38B8FC50FBAF/WhereAmI.app/WhereAmI
Identifier:      WhereAmI
Version:         ??? (???)
Code Type:       ARM (Native)
Parent Process:  launchd [1]

Date/Time:       2011-07-23 18:47:19.093 -0400
OS Version:      iPhone OS 4.3.4 (8K2)
Report Version:  104

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x00000000, 0x00000000
Crashed Thread:  0

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   libsystem_kernel.dylib          0x356d8a1c __pthread_kill + 8
1   libsystem_c.dylib               0x34d543b4 pthread_kill + 52
2   libsystem_c.dylib               0x34d4cbf8 abort + 72
3   libstdc++.6.dylib               0x35434a64 __gnu_cxx::__verbose_terminate_handler() + 376
4   libobjc.A.dylib                 0x35fdd06c _objc_terminate + 104
5   libstdc++.6.dylib               0x35432e36 __cxxabiv1::__terminate(void (*)()) + 46
6   libstdc++.6.dylib               0x35432e8a std::terminate() + 10
7   libstdc++.6.dylib               0x35432f5a __cxa_throw + 78
8   libobjc.A.dylib                 0x35fdbc84 objc_exception_throw + 64
9   CoreFoundation                  0x3504d3c6 -[NSException raise] + 2
10  MapKit                          0x3389bcb2 -[MKMapView setRegion:animated:] + 318
11  WhereAmI                        0x000029cc -[WhereAmIAppDelegate mapView:didUpdateUserLocation:] (WhereAmIAppDelegate.m:52)
12  MapKit                          0x338a11b6 -[MKMapView(UserPositioningInternal) resetUserLocation] + 142
13  MapKit                          0x338a074e -[MKMapView(UserPositioningInternal) locationManagerDidReset:] + 22
14  CoreFoundation                  0x34fbaefc -[NSObject(NSObject) performSelector:withObject:] + 16
15  CoreFoundation                  0x34ff82f2 -[NSArray makeObjectsPerformSelector:withObject:] + 394
16  MapKit                          0x33893802 -[MKLocationManager _reportLocationStatus:] + 34
17  MapKit                          0x338937ce -[MKLocationManager _reportLocationReset] + 14
18  MapKit                          0x33894d24 -[MKLocationManager reset] + 88
19  MapKit                          0x338770a2 -[MKLocationManager applicationResumed:] + 62
20  Foundation                      0x30fa017c _nsnote_callback + 136
21  CoreFoundation                  0x3501c208 __CFXNotificationPost_old + 396
22  CoreFoundation                  0x34fb6ee4 _CFXNotificationPostNotification + 112
23  Foundation                      0x30f9d5cc -[NSNotificationCenter postNotificationName:object:userInfo:] + 64
24  UIKit                           0x3640f720 -[UIApplication _handleApplicationResumeEvent:] + 900
25  UIKit                           0x362b9e20 -[UIApplication handleEvent:withNewEvent:] + 2724
26  UIKit                           0x362b920e -[UIApplication sendEvent:] + 38
27  UIKit                           0x362b8c4c _UIApplicationHandleEvent + 5084
28  GraphicsServices                0x35827e70 PurpleEventCallback + 660
29  GraphicsServices                0x35827efa PurpleEventSignalCallback + 10
30  CoreFoundation                  0x35024a72 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 6
31  CoreFoundation                  0x35026758 __CFRunLoopDoSources0 + 376
32  CoreFoundation                  0x350274e4 __CFRunLoopRun + 224
33  CoreFoundation                  0x34fb7ebc CFRunLoopRunSpecific + 224
34  CoreFoundation                  0x34fb7dc4 CFRunLoopRunInMode + 52
35  GraphicsServices                0x35827418 GSEventRunModal + 108
36  GraphicsServices                0x358274c4 GSEventRun + 56
37  UIKit                           0x362e3d62 -[UIApplication _run] + 398
38  UIKit                           0x362e1800 UIApplicationMain + 664
39  WhereAmI                        0x000027c0 main (main.m:14)
40  WhereAmI                        0x00002768 start + 32

Ich bin sehr neu darin, aber ich vermute, dass die letzte Funktion hier ist:

8   libobjc.A.dylib                 0x35fdbc84 objc_exception_throw + 64
9   CoreFoundation                  0x3504d3c6 -[NSException raise] + 2
10  MapKit                          0x3389bcb2 -[MKMapView setRegion:animated:] + 318
11  WhereAmI                        0x000029cc -[WhereAmIAppDelegate mapView:didUpdateUserLocation:] (WhereAmIAppDelegate.m:52)

Der Methodencode von WHEREAMIAPPDELEGATE.M ist hier:

- (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation{
    // Zoom in on user here
    CLLocationCoordinate2D loc = [userLocation coordinate];
    MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(loc, 250, 250);
    [worldView setRegion:region animated:YES];

}
War es hilfreich?

Lösung

Überprüfen Sie, ob die Region einen gewissen Wert hat. Auch ändern 250 zu 250.0. Gib mir ein Feedback. :)

Andere Tipps

Ich habe dieses Problem mit der 3. Ausgabe des Buches gestoßen und sah, dass es in den 2. Ausgabeforen des Buches beantwortet wurde, aber nicht hier. Das Problem ist, dass das WHEREAMIAPPDELEGATE einen ungültigen Standort erhält, wenn die App länger als 5-10 Minuten vom Laufen im Hintergrund zurückkehrt. Ich bin mir nicht sicher, warum das passiert, aber so habe ich es behoben:

- (void)mapView:(MKMapView *)mapView 
    didUpdateUserLocation:(MKUserLocation *)userLocation
{
    // Here we are... but how do we actually zoom?
    CLLocationCoordinate2D loc = [userLocation coordinate];
    if(CLLocationCoordinate2DIsValid(loc))
    {
        MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(loc, 320, 480);
        [worldView setRegion:region animated:YES];
    }
}

Tut mir leid, einen alten Thread zu "Necro", aber ich dachte, dies könnte jemandem helfen, Hilfe zu suchen. Übrigens verwende ich Xcode 4.3.2 und iOS 5.1.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top