Get current zip code, and show closest results from NSArray

Horray

I have a NSArray of differrent zip codes. I want to get the current users location's zip code, then see if the NSArray has that zip code, and show only the objects that have the same zip code.

So far I can do all that by just getting the user's location, put it in a string, then add a for loop, and add the matching objects to another array.

The problem starts with, what if the NSArray does not have the zip code of the user's location. Is there a way to check the closest results?

Jef

it should be reasonably easy to find the results which are closest numerically, I think you ought be looking at NSPredicate and an enumerateUsingBlock: type method, should be more efficient than any parser you can come up with in as for loop. You could be dealing with the numerals one at a time..

that is let us say your zip codes have five digits, you use a predicate to return a new array with only those codes with the same first number, tens of thousands. then you repeat, so you have a (significantly smaller) array with the same first two digits, thousands... etc..then at the end if you don't have the exact code well the last array will at least have the numerically neighbouring ones. but this of course is only sorting numerically, Im in australia and I don't know about your region, but here they don't always line up so perfectly, they must be laid out onto a grid map which has two dimensions after all (so either they are laid out north-south or east-west, but either way it is likely that neighbouring zip codes will not always be numerically closest). Good luck

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

How to get values from an NSArray after applying filter to NSArrayController in Cocoa

분류에서Dev

trying to get current date in code behind

분류에서Dev

Fetch NSarray from the NSDictionary of NSArray using objectForKey

분류에서Dev

Wordpress get_pages sub nav show current page

분류에서Dev

How to show windows only from the current workspace in Unity switcher?

분류에서Dev

how to get current date from server

분류에서Dev

Get first name from current session PHP

분류에서Dev

Android get text from current context

분류에서Dev

Get list of results from recursive method

분류에서Dev

Get results from AuditCriterion in new class

분류에서Dev

How do I get the first two closest numbers to a target from an array using lodash?

분류에서Dev

How to get current class name in Netbeans code template?

분류에서Dev

Maximo - Get current Workflow position using java code

분류에서Dev

Show current database record

분류에서Dev

How to execute code in a new tmux session - from within current session?

분류에서Dev

ping: show only results

분류에서Dev

How to get current selection value from cake php FormHelper

분류에서Dev

How to get the AST of the current chrome tab from an extension?

분류에서Dev

Get URL of current active tab from Firefox via command line

분류에서Dev

Get ID of closest Div not working twice

분류에서Dev

How to show full results, rather than matched text from regex searches in python

분류에서Dev

get http response code from a url

분류에서Dev

Get Country code from VBA and LDAP

분류에서Dev

zip does'n show me any issue

분류에서Dev

How to get array of objects from current collection and data from another collection in same query

분류에서Dev

Get current SensorEvent value

분류에서Dev

Why do I get "wrong version error" when I add SSl to the Indy Zip Code Lookup example in Delphi 2010?

분류에서Dev

Can't get FiraCode to show despite the font installed and ligatures activated in VS Code in Windows

분류에서Dev

Maps doesn't show the current location anymore

Related 관련 기사

  1. 1

    How to get values from an NSArray after applying filter to NSArrayController in Cocoa

  2. 2

    trying to get current date in code behind

  3. 3

    Fetch NSarray from the NSDictionary of NSArray using objectForKey

  4. 4

    Wordpress get_pages sub nav show current page

  5. 5

    How to show windows only from the current workspace in Unity switcher?

  6. 6

    how to get current date from server

  7. 7

    Get first name from current session PHP

  8. 8

    Android get text from current context

  9. 9

    Get list of results from recursive method

  10. 10

    Get results from AuditCriterion in new class

  11. 11

    How do I get the first two closest numbers to a target from an array using lodash?

  12. 12

    How to get current class name in Netbeans code template?

  13. 13

    Maximo - Get current Workflow position using java code

  14. 14

    Show current database record

  15. 15

    How to execute code in a new tmux session - from within current session?

  16. 16

    ping: show only results

  17. 17

    How to get current selection value from cake php FormHelper

  18. 18

    How to get the AST of the current chrome tab from an extension?

  19. 19

    Get URL of current active tab from Firefox via command line

  20. 20

    Get ID of closest Div not working twice

  21. 21

    How to show full results, rather than matched text from regex searches in python

  22. 22

    get http response code from a url

  23. 23

    Get Country code from VBA and LDAP

  24. 24

    zip does'n show me any issue

  25. 25

    How to get array of objects from current collection and data from another collection in same query

  26. 26

    Get current SensorEvent value

  27. 27

    Why do I get "wrong version error" when I add SSl to the Indy Zip Code Lookup example in Delphi 2010?

  28. 28

    Can't get FiraCode to show despite the font installed and ligatures activated in VS Code in Windows

  29. 29

    Maps doesn't show the current location anymore

뜨겁다태그

보관