My app pulls phone numbers from the IOS address book and then stores them in core data. I've noticed that the IOS address book stores the data with formatting i.e. (650) 555 5555. This causes problems as when you try to send this to an url to call or text it doesn't work.
For other phone numbers entered manually in my app, I have been storing them without formatting and formatting them only on display.
Is there a preferred approach to storing character-free vs. with characters?
It's really up to you and the use you're going to give the numbers.
I've done this in the past and we chose to store phone numbers in with just plain numbers and display them with formatting according to the location since most likely all the contact numbers would be from a specific country or location. That was going to be easier for a person to look at.
Also we could just use the number stored without any modification to just call or send texts because that required the phone without formatting.
The parentheses, hyphens, spaces etc. are all part of the presentation of the data, not of the data itself. Therefore you should store them as pure numbers.
Related
I'm developing a custom keyboard for the iOS operating system and I'm trying to add the auto-suggestion feature. For English dictionary there seems to be no difficulties, but for languages like french I came into a problem regarding accents. See this example: The user tries to write "Chaîne" (chain). the UITextChecker retrieves words until user reaches the "î", after that the it stops, the word list is empty.
The code to retrieve the word list is as follow:
// While user is typing the txt variable is modified...
range = NSMakeRange(0, txt.length);
words = [m_textChecker completionsForPartialWordRange:range inString:txt language:#"fr_FR"];
This problem happens also using Italian and other languages that use accented letters. You do not retrieve "città" (city) while typing "cit..." or "citt..."
Maybe it is my fault in understanding the completionsForPartialWordRange:inString:language method real meaning.
I tried to choose other solutions, for example including an SQLite database importing the Aspell dictionaries, but I'm not sure if it is legal and it will be accepted by Apple review team. Moreover database originating from Aspell are quite big. To solve the latter issue I though to use an optional download feature from the containing app, but I can't figure out how its keyboard extension could access the app's `Documents' folder, because they do not share the same bundle path for that folder.
Can any one help me in understanding the UITextChecker and accented words?
Thank you very much...
I need to feed some substantial text into my first app which will change as the date changes (i.e every day) for a whole month.
This data, I currently have it all on a .doc file which each day's content on that file, properly separated.
What method can I use to store this data in my app and how can I format it in such a way that the app takes the date portion of the text and use that to determine whether or not it should show that particular portion of text for a day.
The app will update the content every month.
I've looked everywhere and the posts I've seen about persistent data just confuse me more. Would this be possible using just plists? The data will ALWAYS be text never images or anything else.
If you post a sample of the text, we can probably give you a better answer (not clear what you're asking), but this sounds like a perfect candidate for core data or sqlite. Once you have the text separated by date/text combos, it becomes pretty simple to do a search by the appropriate date, and show only the relevant text.
By the way, having it in a *.doc format is just going to add unnecessary overhead. If you really want to have it in a flat file, use something like json.
That looks like a bit much for plists. You could use core data or sqlite, but there is also the easier option of having separate plaintext files and reading them as is demonstrated in this question.
We have a system that allows you to scan your credit card on a MSR and from the dump I pull the needed fields such as name/cc/exp. Recently we had to add globalized credit cards to this. For almost all of the card provided, I was able to still pull the information since they seemed to all follow a standard. One exception however was a Maestro card. The format is completely different, and since I neither have one to verify actual number on card vs dumped data, nore have access to any other dumps, it's very hard for me to figure out the correct format of these. I also did some google searching with little luck of extracting data from a MSR dump.
Unlike almost all other cards, track one does not start with "%B" and Track two does not start with ";". Both tracks do appear to end with "?" (based off analyzing the whole dump, not by track). Track 3 does appear to be empty, which is normal.
The whole dump seems to lack any name data and is basically in the format of:
###=###?
###=###=###==#=###?
Note that besides the single #, where I had 3 it was variable length.
Again I only had access to one single dump, which for obvious reason I cannot post here.
If anyone has some example code in any language, or can link me to some help, I'd really appreciate it.
Thanks in advance,
Anthony
Is it possible that the card you are testing is faulty or simply a non standard card that is generally not supported? try to check track data from other maestro cards before assuming your system is at fault.
I say this because ISO 7813, the governing standard for transaction cards is pretty clear regarding the fact that track 2 data begins with start sentinel ";" and that all valid bank cards have a format code "B" following the start sentinel "%" in track 1.
check the standard carefully and make sure your system is parsing correctly:
http://www.gae.ucm.es/~padilla/extrawork/tracks.html
Is there a way to format the phone numbers? For e.g. +11234567890 to +1(123) 456-789. And also is it possible to separate ISD and STD codes in the phone number itself? Since apple is doing the same in IPhone's address book and as well as Mobile application, I believe that there is way to the same (but no idea how to do).
You want NSDataFormatter and probably NSNumberFormatter. Both are classes designed to handle just this type of problem with minimum fuss.
If you handle a lot of phone numbers you might want to go ahead and write a dedicated formatting subclass just for phone numbers. I used to have one that would return properly localized phone numbers e.g. formats for North America vs Europe vs Asia etc depending on the location set for the device.
Phone numbers are one of those common pieces of data whose handling grows surprisingly complex very quickly especially when you start throwing in international variations and various types of extensions like calling cards or voice tree controls.
My Rails app deals a lot with data from third-party APIs (specifically UPS, FedEx, DHL, etc).
What I'd like to do is whenever that data comes in, replace certain phrases with customized phrases.
Example: "On FedEx vehicle for delivery" (which we get from the FedEx API), I'd like to replace with "Out for Delivery."
Is it best to replace the the text on its way in to the database? Or on output? (Talking from an end-user speed perspective)
I'm planning on storing these phrases in our database, so I'm assuming I'd just create a helper that pulls the phrases I want to replace and then run the strings through those using gsub and replace as necessary?
Any tips on making this efficient and easy to manage would be great.
For speed you should replace the phrases when they enter the database. If you do it on output you'll have to do it every time an user requests the data. It is quite obvious that doing it every time will put more load on the server.
You may, however, want to store the original phrases, in case you want to change the wording in the phrases you replace with.
Just a random idea, which might not be applicable depending on how your data is, but maybe you could leverage the i18n framework that's built into Rails for this. The original text could be viewed as a separate language called vendorspeak :-).