-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAddressBook
73 lines (44 loc) · 1.82 KB
/
AddressBook
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
groups := ABAddressBook sharedAddressBook groups.
finis := groups where: groups name = 'FINIS'.
finis valueForProperty: kABGroupNameProperty.
finis members valueForProperty: kABLastNameProperty
people := ABAddressBook sharedAddressBook people.
person := people at: 0.
phones := person valueForProperty: kABPhoneProperty.
addressLists := people valueForProperty: kABAddressProperty.
getAddresses := [:person |
| result addressList |
result := {}.
addressList := (person valueForProperty: kABAddressProperty) mutableCopy.
addressList == nil ifFalse: [
0 to: addressList count - 1 do: [:i |
| address zip |
address := (addressList valueAtIndex: i) mutableCopy.
zip := address objectForKey: kABAddressZIPKey.
(zip hasPrefix: 'A-') ifTrue: [result add: address]]].
result].
getAddresses value: @ (people at: {3, 8}).
getAddresses value: @ people
(getAddresses value: @ people) \ #++
fixZip := [:address |
| zip |
zip := address objectForKey: kABAddressZIPKey.
address setObject: (zip substringFromIndex: 2) forKey: kABAddressZIPKey].
fixZip value: ((getAddresses value: @ (people at: {3, 8})) \ #++).
ABAddressBook sharedAddressBook hasUnsavedChanges
ABAddressBook sharedAddressBook save
person lastName
person allProperties
person valueForProperty: kABJobTitleProperty
phones count
phones labelAtIndex: 1
[:i | phones labelAtIndex: i] value: @@ {0, 1, 2, 3}
phones identifierAtIndex: 1
phones propertyType
ABAddressBook sharedAddressBook people valueForProperty: kABJobTitleProperty
AddressBook := SBApplication applicationWithBundleIdentifier:'com.apple.AddressBook'.
addresses := AddressBook people addresses.
addresses count
addresses zip count
Konstanten:
http://developer.apple.com/mac/library/documentation/UserExperience/Reference/AddressBook/Miscellaneous/AddressBook_Constants/Reference/reference.html