Note that there are some explanatory texts on larger screens.

plurals
  1. POVCard reader not working
    primarykey
    data
    text
    <p>I am new to objective C and I am in a position where I need create an App urgently . I am using XCode 4.2</p> <p>in a part of the App I will be detecting a QR code and getting a VCard in NSString format : I did the function using the following code : -I imported the following to frameworks :</p> <pre><code>AddressBookUI.framework AddressBook.framework </code></pre> <p>in the .h file I wrote :</p> <pre><code>#import &lt;addressBook/AddressBook.h&gt; #import &lt;AddressBookUI/AddressBookUI.h&gt; @interface HellowWorld : UIViewController&lt;ABPeoplePickerNavigationControllerDelegate&gt;{ } -(IBAction)saveContacts; @end </code></pre> <p>in the .m file I wrote :</p> <pre><code>-(IBAction)saveContacts{ NSString *vCardString = test //where the data will be comming from CFDataRef vCardData = (CFDataRef)[vCardString dataUsingEncoding:NSUTF8StringEncoding]; ABAddressBookRef book = ABAddressBookCreate(); ABRecordRef defaultSource = ABAddressBookCopyDefaultSource(book); CFArrayRef vCardPeople = ABPersonCreatePeopleInSourceWithVCardRepresentation(defaultSource, vCardData); for (CFIndex index = 0; index &lt; CFArrayGetCount(vCardPeople); index++) { ABRecordRef person = CFArrayGetValueAtIndex(vCardPeople, index); ABAddressBookAddRecord(book, person, NULL); CFRelease(person); } CFRelease(vCardPeople); CFRelease(defaultSource); ABAddressBookSave(book, NULL); CFRelease(book); } </code></pre> <p>I used this code but it is not working.</p> <p>First it did not compile this line : </p> <pre><code>CFDataRef vCardData = (CFDataRef)[vCardString dataUsingEncoding:NSUTF8StringEncoding]; </code></pre> <p>I had to change it to this : </p> <pre><code>CFDataRef vCardData = (__bridge CFDataRef)[vCardString dataUsingEncoding:NSUTF8StringEncoding]; </code></pre> <p>and after compiling it crashes at this line :</p> <pre><code> for (CFIndex index = 0; index &lt; CFArrayGetCount(vCardPeople); index++) { </code></pre> <p>It gives the following green error : <code>Thread1: Program Received Signal "EXC_BAD_ACCESS"</code>. Any reasons?</p> <p>also is this the only way to save a VCard (in NSString format) in the address book ? any other suggestions ?</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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