I have been Playing around with my iPhone and i recently realized that the Email App of iPhone can recognize if a line within an Email represents an address. Interestingly enough this works with many address Patterns. I tried USA , Germany, France and Spain. In all the cases the address was highlighted as a blue link just as a phone number would be. So my question is what is the algorithm behind this address detection?
Asked
Active
Viewed 796 times
-3
-
Actually what do u want to implement, Specify clearly. Or you want only that how to detect mail-id. – Arpit Kulsreshtha Apr 09 '13 at 09:37
-
Did you ever get an answer to this question? The responses below simply point to black boxes rather than algorithms. – freethebees Oct 01 '14 at 09:29
2 Answers
2
Check UIDataDetectorTypes
in the documentation. You'll find a UIDataDetectorTypeAddress
that detects strings formatted as addresses.
You could then add this detector type to a UITextView
.

tilo
- 14,009
- 6
- 68
- 85
-
I did not mean Email Addresses.I meant Location Addresses.How Can iPhone recognize all types of location Addresses, USA , Spain, france ,.... – FE RY Apr 09 '13 at 10:00
-
`UIDataDetectorTypeAddress` will detect these adresses (there is no 'email' in 'UIDataDetectorTypeAddress'. – tilo Apr 09 '13 at 10:20
-
Thanks Tilo, but i have not gotten the answer to my question yet.There must be a way that this UIDataDetectorTypeAddress thing detects an address, no matter which country it belongs to. That's what i want to know.I don't need any implementation , just a logic how to do it. – FE RY Apr 09 '13 at 10:40
-
Sure, it is done _somehow_, but Apple most likely won't tell you how they did it. There are companies out there offering this kind of service (for money). You'll find a possible answer to your question here: http://stackoverflow.com/a/16444/184245 – tilo Apr 09 '13 at 10:53
1
You can set theObj.dataDetectorTypes = UIDataDetectorTypeAddress;
Or you can implement like this
UITextView *theObj;
theObj = [[UITextView alloc] initWithFrame:CGRectMake(65, 10, 225, 65)];
theObj.text = @"sample@mail.com";
theObj.editable = NO;
theObj.dataDetectorTypes = UIDataDetectorTypeAddress;
[myview theObj];

Arpit Kulsreshtha
- 2,452
- 2
- 26
- 52
-
I did not mean Email Addresses.I meant Location Addresses.How Can iPhone recognize all types of location Addresses, USA , Spain, france ,.... – FE RY Apr 09 '13 at 09:52