Reputation: 1326
Now I generate QR Code with simple text and for that I use below demo project.
IOS_QR_Code_Generator
And for generating QR code:
NSString *code = @"JAY RAPARKA SIMPLE Encoding string";
Barcode *barcode = [[Barcode alloc] init];
self.view.backgroundColor = [UIColor whiteColor];
[barcode setupQRCode:code];
ivQRCode.image = barcode.qRBarcode;
Right now I just encode "JAY RAPARKA SIMPLE Encoding string" this simple text but I want to generate QR code for more complex data like (Contect information, link/URL, account balance on the base of id,etc..). So please any one done this earlier than please help me.
Thank you!
For decoding I use ZBar sdk and it also works properly and encoding also work but I just want to generate QR for more data.
Upvotes: 0
Views: 533
Reputation: 1326
You can use this code
- (NSString *)vCardRepresentation
{
NSMutableArray *mutableArray = [[NSMutableArray alloc] init];
[mutableArray addObject:@"BEGIN:VCARD"];
[mutableArray addObject:@"VERSION:3.0"];
[mutableArray addObject:[NSString stringWithFormat:@"FN:%@", self.name]];
[mutableArray addObject:[NSString stringWithFormat:@"ADR:;;%@",
[self addressWithSeparator:@";"]]];
if (self.phone != nil)
{
[mutableArray addObject:[NSString stringWithFormat:@"TEL:%@", self.phone]];
}
[mutableArray addObject:[NSString stringWithFormat:@"GEO:%g;%g",
self.latitudeValue, self.longitudeValue]];
[mutableArray addObject:[NSString stringWithFormat:@"URL:http://%@",
self.website]];
[mutableArray addObject:@"END:VCARD"];
NSString *string = [mutableArray componentsJoinedByString:@"\n"];
[mutableArray release];
return string;
}
OR you can generate String with saparator like,
NSString *str = "Name : Jay, Work : IOSDeveloper";
and after that saperate this using
NSArray *ary = [mystring componentsSeparatedByString:@","];
now you can use this ary with index.
Upvotes: 0
Reputation: 960
You can create contact information by giving text in bellow format
BEGIN:VCARD
VERSION:2.1
N:;Company Name
FN:Company Name
ORG:Company Name
TEL;WORK;VOICE;PREF:+16045551212
TEL;WORK;FAX:+16045551213
ADR;WORK;POSTAL;PARCEL;DOM;PREF:;;123 main street;vancouver;bc;v0v0v0;canada
EMAIL;INTERNET;PREF:[email protected]
URL;WORK;PREF:http://www.example.com/
NOTE:http://www.example.com/
CATEGORIES:BUSINESS,WORK
UID:A64440FC-6545-11E0-B7A1-3214E0D72085
REV:20110412165200
END:VCARD
Upvotes: 2