Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>For anyone else that needs a solution for this, I've created a category class for CLPlacemark that returns the short state string. All you need to do is call <code>myPlacemark shortState</code></p> <p>CLPlacemark+ShortState.h</p> <pre><code>#import &lt;CoreLocation/CoreLocation.h&gt; #import &lt;Foundation/Foundation.h&gt; @interface CLPlacemark (ShortState) - (NSString *)shortState; @end </code></pre> <p>CLPlacemark+ShortState.m</p> <pre><code>#import "CLPlacemark+ShortState.h" @interface CLPlacemark (ShortStatePrivate) - (NSDictionary *)nameAbbreviations; @end @implementation CLPlacemark (ShortState) - (NSString *)shortState { NSString *state = [self.administrativeArea lowercaseString]; if (state.length==0) return nil; return [[self nameAbbreviations] objectForKey:state]; } - (NSDictionary *)nameAbbreviations { static NSDictionary *nameAbbreviations = nil; static dispatch_once_t onceToken; dispatch_once(&amp;onceToken, ^{ nameAbbreviations = [NSDictionary dictionaryWithObjectsAndKeys: @"AL",@"alabama", @"AK",@"alaska", @"AZ",@"arizona", @"AR",@"arkansas", @"CA",@"california", @"CO",@"colorado", @"CT",@"connecticut", @"DE",@"delaware", @"DC",@"district of columbia", @"FL",@"florida", @"GA",@"georgia", @"HI",@"hawaii", @"ID",@"idaho", @"IL",@"illinois", @"IN",@"indiana", @"IA",@"iowa", @"KS",@"kansas", @"KY",@"kentucky", @"LA",@"louisiana", @"ME",@"maine", @"MD",@"maryland", @"MA",@"massachusetts", @"MI",@"michigan", @"MN",@"minnesota", @"MS",@"mississippi", @"MO",@"missouri", @"MT",@"montana", @"NE",@"nebraska", @"NV",@"nevada", @"NH",@"new hampshire", @"NJ",@"new jersey", @"NM",@"new mexico", @"NY",@"new york", @"NC",@"north carolina", @"ND",@"north dakota", @"OH",@"ohio", @"OK",@"oklahoma", @"OR",@"oregon", @"PA",@"pennsylvania", @"RI",@"rhode island", @"SC",@"south carolina", @"SD",@"south dakota", @"TN",@"tennessee", @"TX",@"texas", @"UT",@"utah", @"VT",@"vermont", @"VA",@"virginia", @"WA",@"washington", @"WV",@"west virginia", @"WI",@"wisconsin", @"WY",@"wyoming", nil]; }); return nameAbbreviations; } @end </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload