Discussion Forums  >  Maps, Device Location, Tracking

Replies: 19    Views: 2136

Nodderz
Aspiring developer
Profile
Posts: 38
Reg: Dec 02, 2012
Adelaide
2,230
02/17/13 11:18 PM (11 years ago)

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Invalid Region

Hey guys, this is the error I am getting when my map trys to load after it has dropped all pins it then crashes. *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Invalid Region <center:+0.51807480, +28.98002975 span:+177.61452263, +450.00000000>' *** First throw call stack: (0x2d3b012 0x2b60e7e 0x2dc3fb1 0x21c578d 0x6da67 0xefa5b3 0x2cfa376 0x2cf9e06 0x2ce1a82 0x2ce0f44 0x2ce0e1b 0x37ad7e3 0x37ad668 0x1346ffc 0x4c156 0x2345 0x1) libc++abi.dylib: terminate called throwing an exception I am very new to developing apps and this is my first one, any help would be amazing! thanks! Also I am using, Xcode 4.6, iOS 6.1 (i think).
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
02/18/13 12:12 AM (11 years ago)
Keep in mind your code might be slightly different. But your 'region' is causing problems. I'm still learning this, but I think the 'region' is sort of like the 'view' of the map which encompasses the area of interest. I would drop a pin on my maps, and they'd be there, but the map would never actually 'go' to where the pin dropped until I correctly defined my region. Here is the code I used. be sure to change the parts (the name of my 'mapView' is 'smugView' and my coordinate sources may or may not work for you. Here's the code I use: MKCoordinateRegion region; region.center.latitude = [appDelegate.rootApp.rootDevice.deviceLatitude doubleValue]; region.center.longitude = [appDelegate.rootApp.rootDevice.deviceLongitude doubleValue]; region.span.latitudeDelta = 0.05; region.span.longitudeDelta = 0.05; region = [smugView regionThatFits:region]; [smugView setRegion:region animated:TRUE]; [smugView release]; This particular bit of code was out of my 'viewDidLoad' call from the 'm' file that created my maps. the basic order of things were: I defined my mapView, I defined my region, I dropped my pins. set your delta value at '0.1' or maybe '0.2' to get a better view, and edit as needed to bring the region/view a little closer as required. Hope it somehow helps... Cheers! -- Smug
 
Nodderz
Aspiring developer
Profile
Posts: 38
Reg: Dec 02, 2012
Adelaide
2,230
like
02/18/13 12:21 AM (11 years ago)
wow thanks alot smug! however, sorry for the stupid questions, as i said i'm still learning. because i made the app through BT what part of the BT_screen_map.m (I'm assuming is the page) should i be removing and replacing/editing with your code?
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
02/18/13 12:32 AM (11 years ago)
Well, I did this on a plugin I created, and it's in the process of being approved, so until it's released I can't say 'go here and look' just yet... I didn't fool with the BT_screen_map.m file... I didn't use it in my plugin. BUT (make a copy of your original before you edit 'too' heavily, just in case) the 'region' part of the BT_screen_map.m file starts around line 411 and starts defining values (to get xcode line numbers: prefs, text editing, editing, check the 'line numbers' box) region definition for portrait is 425-428, and landscape is 430-433. I'd 'try' changing the delta values from 1.1 to 2, or 3, and see what that did. Adjust according to results. Hope this helps, but let me know what doesn't make sense... Cheers! -- Smug
 
Nodderz
Aspiring developer
Profile
Posts: 38
Reg: Dec 02, 2012
Adelaide
2,230
like
02/18/13 12:43 AM (11 years ago)
ah yes okay, firstly, this is all that comes up under that area, - //region MKCoordinateRegion region; the delta values you talk about, you mean the span.long/lat? Also, when pasting your code the errors i gain are app delegate (which i can easily edit) and then the rootApp has an error, i didnt touch as i would prefer clarification. Thanks for all your help!
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
02/18/13 12:49 AM (11 years ago)
Well, all of that is done for you in BT_screen_map.m, so you won't need any of my code in this instance... only if you were making it from scratch. So you'll really only want to make small edits in that area, not a complete rewrite... for instance change the following: region.span.latitudeDelta = fabs(topLeftCoord.latitude - bottomRightCoord.latitude) * 1.1; region.span.longitudeDelta = fabs(bottomRightCoord.longitude - topLeftCoord.longitude) * 1.1; from '1.1' to '2' or higher, and see what happens. Cheers! -- Smug (I said 'my code'. <snort> I stole all that from David, lol!)
 
Nodderz
Aspiring developer
Profile
Posts: 38
Reg: Dec 02, 2012
Adelaide
2,230
like
02/18/13 12:56 AM (11 years ago)
ok, yes I understand. I changed the delta values from 1.1 to 2 and 3 and both times the app still crashes after dropping pins, HOWEVER, the *** Terminating app due to uncaught exception 'NSInvalidArgumentException* is now gone. The last thing the output box states is BT_screen_map:mapView:centerMap (lldb) And the breakpoint is on line - for(annotation in self.mapView.annotations){ Sorry if this becomes overwhelming at any stage you've been a huge help so far!
 
Nodderz
Aspiring developer
Profile
Posts: 38
Reg: Dec 02, 2012
Adelaide
2,230
like
02/18/13 01:07 AM (11 years ago)
sorry my mistake i added a breakpoint the output box still states *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Invalid Region <center:nan, nan span:nan, nan> *** First throw call stack: (0x2d3b012 0x2b60e7e 0x2dc3fb1 0x21c578d 0x6da58 0xefa5b3 0x2cfa376 0x2cf9e06 0x2ce1a82 0x2ce0f44 0x2ce0e1b 0x37ad7e3 0x37ad668 0x1346ffc 0x4c146 0x2335 0x1) libc++abi.dylib: terminate called throwing an exception (lldb) apologies It is a SIGABRT error on this line int retVal= UIApplicationMain(argc,argv,@"UIApplication",@"kebapp_appDelegate"); If it helps!
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
02/18/13 01:15 AM (11 years ago)
Ok, well, it's still not happy with your region. For the time being, replace the original values. Remove your 'pins'. Add them one at a time and see if one of your locations is causing an issue. That SIGABRT error usually happens when I've done something that is 'accepted' but not 'acceptable' if you know what I mean... So let's get to a working screen map, and then one by one try and break it :) Cheers! -- Smug
 
Nodderz
Aspiring developer
Profile
Posts: 38
Reg: Dec 02, 2012
Adelaide
2,230
like
02/18/13 01:19 AM (11 years ago)
okay sounds like a plan! I have added over 900 pins within australia, so im going to cut the locations from the code and replace them 1 by 1 after the map works by itself, correct?
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
02/18/13 01:38 AM (11 years ago)
Holy mackerel! 900? In that case, I'd go by the rule of halves. Take out your points. Test it. Replace half of your points. Test it. If it works, put more in. If it doesn't, take out half. Test it. Keep putting in/taking out halves until you start to recreate the problem, and narrow it down from there. These points are all in Australia, right? Not 899 in Australia and one in Bejing or anything...? Cheers! -- Smug
 
Nodderz
Aspiring developer
Profile
Posts: 38
Reg: Dec 02, 2012
Adelaide
2,230
like
02/18/13 02:31 AM (11 years ago)
They are all in Australia yes, however I've noticed on the failed load ups there's been a few strays going to USA and malaysia. When i cut all the locations data from the config.txt then simulator still seems to be loading the locations, any ideas?
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
02/18/13 03:12 AM (11 years ago)
Where are they originating from? Have you put 900 questions in your BT Control panel? It that is the case, as soon as it reports and downloads a fresh config file, it'll overwrite the questions... Hmmm... Try this: Delete the app from your device, and/or reset your simulator. Basically 'clean it out'. Then rerun/reload the app on your simulator or device. When it runs, and asks if you want to reload data, say 'NO'. That should allow you to work with your current config file without making major concessions on everything else. Cheers! -- Smug
 
Nodderz
Aspiring developer
Profile
Posts: 38
Reg: Dec 02, 2012
Adelaide
2,230
like
02/18/13 03:28 AM (11 years ago)
it now seems the config data is invalid. talk about frustrating!
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
02/18/13 03:33 AM (11 years ago)
That config.txt file is just a bunch of JSON, which isn't that bad once you get used to it, but it's annoying until then. Take your config file, and when you make changes, run it through 'jsonlint.com' and make sure it's valid. Jsonlint will take it and format it in a much easier to look at format. Then take the whole config file and run it through json lint. Then copy/paste the new formatted config data into a text editor. I prefer Text Wrangler for the Mac, Notepad ++ for windows. You have to be careful when taking out childItems, because it's really particular about opening/closing brackets, comma separators and such. Not impossible, but certainly tedious at times. Cheers! -- Smug
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
02/18/13 03:42 AM (11 years ago)
Heh. I just thought of something. For the moment, forget 'this' screen. Create a new map screen in your project. This will still utilize the same code. Then you don't have to worry about the config file; this screen won't have any questions. You can go from there. But I wouldn't reload 900 questions in the control panel on this; use an external file of childItems. Far easier to deal with. Cheers! -- Smug
 
Nodderz
Aspiring developer
Profile
Posts: 38
Reg: Dec 02, 2012
Adelaide
2,230
like
02/18/13 12:54 PM (11 years ago)
thanks for all your feedback mate! i'll get on top of it as soon as I get home from work! i'll keep you posted.
 
Nodderz
Aspiring developer
Profile
Posts: 38
Reg: Dec 02, 2012
Adelaide
2,230
like
02/18/13 10:42 PM (11 years ago)
Smug i cannot begin to thank you enough! it is now running 100% thanks for all your input!
 
Bernard
Lost but trying
Profile
Posts: 5
Reg: Nov 10, 2012
France
2,100
like
06/05/13 08:24 AM (11 years ago)
Hi, I encounter the same (?) problem here ... LocationMap, i added in xCode (BT_config) thousand of POIs at the correct format and there is a bug on simulator : *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Invalid Region <center:+13.59049890, +0.00000000 span:+177.54592614, +450.00000000>' Can't find a solution, could someone help me please ?
 
Nodderz
Aspiring developer
Profile
Posts: 38
Reg: Dec 02, 2012
Adelaide
2,230
like
06/06/13 02:19 AM (11 years ago)
i had to go through the code and look at all of the longs/lat's. anything that looked completely different to the rest, IE if all the locations are a -3.00.. and one of them is 3.00 also look for the differences is numbers. i did that, took out about 3 or 4 locations and it worked fine.
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.