I hope some one can help me. I'm developing a iOS 6 app on xcode 4.5.2, the app use significant-change location service, it detects the localization uses reverse geocoding and upload the country code, adminArea, subAdminArea, locality and sublocality to an online DB using a web service. on the iphone simulator it works fine, but on iOS devices it directly get closed with no reason. if i deactivate the location services to my app it runs ok, but when it have permission to use these it closes within one second.
this is the code:
#import "searchViewController.h"
#import <CoreLocation/CoreLocation.h>
#import "resultViewController.h"
@interface searchViewController () <UIPickerViewDataSource, UIPickerViewDelegate, CLLocationManagerDelegate, NSXMLParserDelegate>
@property (weak, nonatomic) IBOutlet UITextView *errorSearchTextView;
- (IBAction)searchButton:(id)sender;
@property (weak, nonatomic) IBOutlet UIPickerView *bloodTypePicker;
@end
@implementation searchViewController
@synthesize bloodType,locationManager,geocoder, webData, xmlParser, soapResults, localizacion, usuarios, correos, coincidencias;
- (void)viewDidLoad
{
[super viewDidLoad];
bloodType = [[NSArray alloc] initWithObjects:@"A+", @"A-", @"B+", @"B-", @"O+", @"O-", @"AB+", @"AB-", nil];
[self startLocating];//here is where i start the location monitoring
// Do any additional setup after loading the view.
}
//this is the metod that starts the location manager.
- (void) startLocating
{
if ([CLLocationManager locationServicesEnabled])//si los servicios de localizacion estan activados.
{
if (nil == locationManager) {
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
[locationManager startMonitoringSignificantLocationChanges];
}
} else
{
self.errorSearchTextView.text = NSLocalizedString(@"location services are not available, app will not work properly, please activate these and restart the app.", @"localization not available");
}
}
//these are the methods called when a location update is received.
-(void) locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{
CLLocation *location = [locations lastObject];
[self geocoder:location];
localizacion = 0;
}
//metodo para el geocoder
-(void) geocoder:(CLLocation *)location
{
if (!geocoder) geocoder = [[CLGeocoder alloc] init];
[geocoder reverseGeocodeLocation:location completionHandler:^(NSArray *placemarks, NSError *error) {
if ([placemarks count]>0)
{
NSString *usuario = [[NSUserDefaults standardUserDefaults] stringForKey:@"usuario"];
CLPlacemark *place = [placemarks objectAtIndex:0];
NSURL *url = [NSURL URLWithString:@"here goes the web service url"];
NSMutableString *soapMessage = [[NSMutableString alloc] init];
[soapMessage appendString:@"<soapenv:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:urn=\"urn:localizacionWSDL\">"
"<soapenv:Header/>"
"<soapenv:Body>"
"<urn:actualiza soapenv:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">"
"<username xsi:type=\"xsd:string\">"];
[soapMessage appendString:usuario];
[soapMessage appendString:@"</username>"
"<latitude xsi:type=\"xsd:string\">"];
[soapMessage appendString:[NSString stringWithFormat:@"%f",location.coordinate.latitude] ];
[soapMessage appendString:@"</latitude>"
"<longitude xsi:type=\"xsd:string\">"];
[soapMessage appendString:[NSString stringWithFormat:@"%f",location.coordinate.longitude]];
[soapMessage appendString:@"</longitude>"
"<countryCode xsi:type=\"xsd:string\">"];
[soapMessage appendString:place.ISOcountryCode];
[soapMessage appendString:@"</countryCode>"
"<adminArea xsi:type=\"xsd:string\">"];
[soapMessage appendString:place.administrativeArea];
[soapMessage appendString:@"</adminArea>"
"<subAdminArea xsi:type=\"xsd:string\">"];
[soapMessage appendString:place.subAdministrativeArea];
[soapMessage appendString:@"</subAdminArea>"
"<locality xsi:type=\"xsd:string\">"];
[soapMessage appendString:place.locality];
[soapMessage appendString:@"</locality>"
"<subLocality xsi:type=\"xsd:string\">"];
[soapMessage appendString:place.subLocality];
[soapMessage appendString:@"</subLocality>"
"</urn:actualiza>"
"</soapenv:Body>"
"</soapenv:Envelope>"];
NSMutableURLRequest *theResquest = [NSMutableURLRequest requestWithURL:url];
NSString *messageLength = [NSString stringWithFormat:@"%d", [soapMessage length]];
[theResquest addValue:@"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[theResquest addValue:@"urn:LoginAction" forHTTPHeaderField:@"SOAPAction"];
[theResquest addValue:messageLength forHTTPHeaderField:@"Content-Length"];
[theResquest setHTTPMethod:@"POST"];
[theResquest setHTTPBody:[soapMessage dataUsingEncoding:NSUTF8StringEncoding]];
webData = [NSMutableData data];
localizacion = 0;
NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theResquest delegate:self];
if (theConnection) {
self.errorSearchTextView.text = NSLocalizedString(@"BloodyHelp is updating your data.", @"updating location");
} else {
self.errorSearchTextView.text = NSLocalizedString(@"Conection error.\n", @"connection error updating");
}
}
}];
}
I really don't know what to do. cause in the simulator everything works fine. P.D. I'm new progamming at objetive-c
Edit: to add crash report
Incident Identifier: C14368BA-39ED-454F-930C-1D2CB94FB299
CrashReporter Key: 1eeb5e6ac17a73185e6d73aeb7aa4da7e7edab94
Hardware Model: iPad3,3
Process: XXXX [2221]
Path: /var/mobile/Applications/901983D5-A1AA-4642-A858-9E211D0AA09E/xxxx.app/xxxx
Identifier: xxxxxx
Version: ??? (???)
Code Type: ARM (Native)
Parent Process: launchd [1]
Date/Time: 2013-03-01 11:35:58.829 -0600
OS Version: iOS 6.1.2 (10B146)
Report Version: 104
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Crashed Thread: 0
Last Exception Backtrace:
(0x3302629e 0x3aebf97a 0x330261c0 0x32ff576e 0x6fba8 0x3b2d711a 0x3b2d64b2 0x3b2db1b8 0x32ff9f36 0x32f6ceb8 0x32f6cd44 0x36b1f2e6 0x34e822fc 0x6d7ea 0x3b2f6b1c)
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x3b3bd350 0x3b3ac000 + 70480
1 libsystem_c.dylib 0x3b33411e 0x3b305000 + 192798
2 libsystem_c.dylib 0x3b37096e 0x3b305000 + 440686
3 libc++abi.dylib 0x3a90ed4a 0x3a90b000 + 15690
4 libc++abi.dylib 0x3a90bff4 0x3a90b000 + 4084
5 libobjc.A.dylib 0x3aebfa74 0x3aeb7000 + 35444
6 libc++abi.dylib 0x3a90c078 0x3a90b000 + 4216
7 libc++abi.dylib 0x3a90c110 0x3a90b000 + 4368
8 libc++abi.dylib 0x3a90d50e 0x3a90b000 + 9486
9 libobjc.A.dylib 0x3aebf9ba 0x3aeb7000 + 35258
10 CoreFoundation 0x330261c0 0x32f64000 + 795072
11 CoreFoundation 0x32ff576e 0x32f64000 + 595822
12 appname 0x0006fba8 0x6c000 + 15272
13 libdispatch.dylib 0x3b2d711c 0x3b2d5000 + 8476
14 libdispatch.dylib 0x3b2d64b4 0x3b2d5000 + 5300
15 libdispatch.dylib 0x3b2db1b8 0x3b2d5000 + 25016
16 CoreFoundation 0x32ff9f36 0x32f64000 + 614198
17 CoreFoundation 0x32f6ceb8 0x32f64000 + 36536
18 CoreFoundation 0x32f6cd44 0x32f64000 + 36164
19 GraphicsServices 0x36b1f2e6 0x36b1a000 + 21222
20 UIKit 0x34e822fc 0x34e2b000 + 357116
21 appname 0x0006d7ea 0x6c000 + 6122
22 libdyld.dylib 0x3b2f6b1c 0x3b2f5000 + 6940
Thread 1 name: Dispatch queue: com.apple.libdispatch-manager
Thread 1:
0 libsystem_kernel.dylib 0x3b3ad648 0x3b3ac000 + 5704
1 libdispatch.dylib 0x3b2dd974 0x3b2d5000 + 35188
2 libdispatch.dylib 0x3b2dd654 0x3b2d5000 + 34388
Thread 2 name: WebThread
Thread 2:
0 libsystem_kernel.dylib 0x3b3aceb4 0x3b3ac000 + 3764
1 libsystem_kernel.dylib 0x3b3ad048 0x3b3ac000 + 4168
2 CoreFoundation 0x32ffb040 0x32f64000 + 618560
3 CoreFoundation 0x32ff9d9e 0x32f64000 + 613790
4 CoreFoundation 0x32f6ceb8 0x32f64000 + 36536
5 CoreFoundation 0x32f6cd44 0x32f64000 + 36164
6 WebCore 0x38f52500 0x38f48000 + 42240
7 libsystem_c.dylib 0x3b31630e 0x3b305000 + 70414
8 libsystem_c.dylib 0x3b3161d4 0x3b305000 + 70100
Thread 3:
0 libsystem_kernel.dylib 0x3b3bdd98 0x3b3ac000 + 73112
1 libsystem_c.dylib 0x3b30bcf6 0x3b305000 + 27894
2 libsystem_c.dylib 0x3b30ba12 0x3b305000 + 27154
3 libsystem_c.dylib 0x3b30b8a0 0x3b305000 + 26784
Thread 4:
0 libsystem_kernel.dylib 0x3b3bdd98 0x3b3ac000 + 73112
1 libsystem_c.dylib 0x3b30bcf6 0x3b305000 + 27894
2 libsystem_c.dylib 0x3b30ba12 0x3b305000 + 27154
3 libsystem_c.dylib 0x3b30b8a0 0x3b305000 + 26784
Thread 5 name: com.apple.NSURLConnectionLoader
Thread 5:
0 libsystem_kernel.dylib 0x3b3aceb4 0x3b3ac000 + 3764
1 libsystem_kernel.dylib 0x3b3ad048 0x3b3ac000 + 4168
2 CoreFoundation 0x32ffb040 0x32f64000 + 618560
3 CoreFoundation 0x32ff9d9e 0x32f64000 + 613790
4 CoreFoundation 0x32f6ceb8 0x32f64000 + 36536
5 CoreFoundation 0x32f6cd44 0x32f64000 + 36164
6 Foundation 0x338b93d0 0x3388c000 + 185296
7 Foundation 0x3393ce80 0x3388c000 + 724608
8 libsystem_c.dylib 0x3b31630e 0x3b305000 + 70414
9 libsystem_c.dylib 0x3b3161d4 0x3b305000 + 70100
Thread 6:
0 libsystem_kernel.dylib 0x3b3bdd98 0x3b3ac000 + 73112
1 libsystem_c.dylib 0x3b30bcf6 0x3b305000 + 27894
2 libsystem_c.dylib 0x3b30ba12 0x3b305000 + 27154
3 libsystem_c.dylib 0x3b30b8a0 0x3b305000 + 26784
Thread 7 name: com.apple.CFSocket.private
Thread 7:
0 libsystem_kernel.dylib 0x3b3bd594 0x3b3ac000 + 71060
1 CoreFoundation 0x32fff1f2 0x32f64000 + 635378
2 libsystem_c.dylib 0x3b31630e 0x3b305000 + 70414
3 libsystem_c.dylib 0x3b3161d4 0x3b305000 + 70100
Thread 8:
0 libsystem_kernel.dylib 0x3b3bdd98 0x3b3ac000 + 73112
1 libsystem_c.dylib 0x3b30bcf6 0x3b305000 + 27894
2 libsystem_c.dylib 0x3b30ba12 0x3b305000 + 27154
3 libsystem_c.dylib 0x3b30b8a0 0x3b305000 + 26784
Thread 0 crashed with ARM Thread State (32-bit):
r0: 0x00000000 r1: 0x00000000 r2: 0x00000000 r3: 0x3ceb1534
r4: 0x00000006 r5: 0x3ceb1b88 r6: 0x1f0e3e24 r7: 0x2fd93c74
r8: 0x1f0e3e00 r9: 0x00000300 r10: 0x38ac0a46 r11: 0x38ac0ce8
ip: 0x00000148 sp: 0x2fd93c68 lr: 0x3b334123 pc: 0x3b3bd350
cpsr: 0x00000010
Binary Images:
Ther is more but it's too long. it's enough?
edit i got the console out:
Mar 1 22:08:26 iPad-de-xxx locationd[45] <Notice>: client 'com.appname' starting significant location changes
Mar 1 22:08:26 iPad-de-xxx awdd[3079] <Error>: libMobileGestalt copySystemVersionDictionaryValue: Could not lookup ReleaseType from system version dictionary
Mar 1 22:08:26 iPad-de-xxx awdd[3079] <Error>: CoreLocation: CLClient is deprecated. Will be obsolete soon.
Mar 1 22:08:49 iPad-de-xxx awdd[3080] <Error>: libMobileGestalt copySystemVersionDictionaryValue: Could not lookup ReleaseType from system version dictionary
Mar 1 22:08:49 iPad-de-xxx awdd[3080] <Error>: CoreLocation: CLClient is deprecated. Will be obsolete soon.
Mar 1 22:08:52 iPad-de-xxx appname copy[3078] <Error>: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString appendString:]: nil argument'
*** First throw call stack:
(0x330262a3 0x3aebf97f 0x330261c5 0x32ff5773 0xfb85 0x3b2d711f 0x3b2d64b7 0x3b2db1bd 0x32ff9f3b 0x32f6cebd 0x32f6cd49 0x36b1f2eb 0x34e82301 0xd7c7 0x3b2f6b20)
Mar 1 22:08:52 iPad-de-xxxx ReportCrash[3082] <Notice>: Formulating crash report for process BloodyHelp copy[3078]
Mar 1 22:08:52 iPad-de-xxxxx com.apple.launchd[1] (UIKitApplication:com.appname[0x9e96][3078]) <Warning>: (UIKitApplication:com.appname[0x9e96]) Job appears to have crashed: Abort trap: 6
Mar 1 22:08:52 iPad-de-xxxxbackboardd[26] <Warning>: Application 'UIKitApplication:com.appname[0x9e96]' exited abnormally with signal 6: Abort trap: 6
Mar 1 22:08:52 iPad-de-Shimon ReportCrash[3082] <Error>: libMobileGestalt copySystemVersionDictionaryValue: Could not lookup ReleaseType from system version dictionary
Mar 1 22:08:52 iPad-de-xxx ReportCrash[3082] <Notice>: Saved crashreport to /var/mobile/Library/Logs/CrashReporter/appname copy_2013-03-01-220852_iPad-de-xxxx plist using uid: 0 gid: 0, synthetic_euid: 501 egid: 0
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString appendString:]: nil argument'
I finally solve this, the crash logs and the console out was the point to find the exact point of the error and solve it, the problem was not at the location services, the problem was than after make gocoding the sub Adminarea was null and i was trying to append to a string, since it's value was nil it trows an exception and close.
the solution was to create this
NSString *subAdminArea = [NSString StringWithFormat:@"%d",place.subAdministrativeArea];
so if the value of place.subAdministrativeArea is nil it is an "" Strging.
advice: to solve the problem connect the device to xcode and make the error happen while you see console out, (you can put " console flags" with NSLog to know where is the error.
Thanks!!
User contributions licensed under CC BY-SA 3.0