Anniversary from contacts in iPhone [closed] - iphone

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I'm able to get birth dates from contacts but not the anniversary dates on iPhone. I have used KABPersonAnniversaryLabel but it is giving an error.

This code will fetch anniversary for all contacts,
ABAddressBookRef addressBook = ABAddressBookCreate();
CFArrayRef people = ABAddressBookCopyArrayOfAllPeople(addressBook);
for (CFIndex i = 0; i < CFArrayGetCount(people); i++) {
ABRecordRef person = CFArrayGetValueAtIndex(people, i);
ABMultiValueRef anniversaries = ABRecordCopyValue(person, kABPersonDateProperty);
NSString *anniversaryLabel;
for (CFIndex j=0; j < ABMultiValueGetCount(anniversaries); j++) {
anniversaryLabel = (NSString*)ABMultiValueCopyLabelAtIndex(anniversaries, j);
if([anniversaryLabel isEqualToString:(NSString *)kABPersonAnniversaryLabel])
{
NSDate *anniversaryDate=(NSDate *)ABMultiValueCopyValueAtIndex(anniversaries, j);
NSLog(#"%#",anniversaryDate);
}
}
CFRelease(anniversaries);
}
CFRelease(addressBook);
CFRelease(people);

Related

How can i check the array has object or not [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
i want to check if the old array has object or not if the old array has the object it should show me the button if the oldArray has zero object the button should be hidden the code is given below thanks...
-(void)viewWillAppear:(BOOL)animated
{
GET_DEFAULTS
NSMutableArray *array = [defaults objectForKey:kShouldResume];
NSData *dataRepresentingSavedArray = [defaults objectForKey:kShouldResume];
if (dataRepresentingSavedArray != nil)
{
NSArray *oldSavedArray = [NSKeyedUnarchiver unarchiveObjectWithData:dataRepresentingSavedArray];
if (oldSavedArray != nil)
{
array = [[NSMutableArray alloc] initWithArray:oldSavedArray];
if ([oldSavedArray containsObject])
{
btnResumeGame.hidden=NO;
}
else
{
btnResumeGame.hidden=YES;
}
}
else
{
array = [[NSMutableArray alloc] init];
}
}
}
Array has property count.
You can check weather count is zero or more than that as you require..
like
oldSavedArray.count
use this code:
if ( [oldSavedArray count]>0 ){
btnResumeGame.hidden=NO;
}
else{
btnResumeGame.hidden=YES;
}

Transforming NSMutableArray values [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
I've been looking for this, but can't find the answer.
I have an NSMutableArray with values who_1, what_2, where_3 etc.
I want to transform this into who, what, where etc.
I already have the value of the integer as a variable, and _ is just a string.
What steps should I take to have all these arrayvalues transformed?
NSArray * arrB = [[NSArray alloc]initWithObjects:#"apple_a",#"ball_b",#"cat_c",#"doll_d",nil];
NSMutableArray * arrA = [[NSMutableArray alloc]init];
for(NSString *strData in arrB)
{
NSArray *arr = [strData componentsSeparatedByString:#"_"];
[arrA addObject:[arr objectAtIndex:0]];
}
and this would be your output
arrA:(
apple,
ball,
cat,
doll
)
You need to apply logic for that, You cant find answers to tricky Questions :)
You need to run a loop.
Separate string with '_'
Loop
for(NSString *s in ary)
{
NSArray *a = [s componentsSeparatedByString:#"_"];
[anotherArray addObject:[a objectAtIndex:0]];
}
and update your array..
Following might help you -
NSRange range = [string rangeOfString:#"_"];
NSString *finalString = [originalString substringToIndex:range.location];
you can have this in loop.
Or you can go for componentSeperatedByStrings.
This might help you
NSMutableArray *tmpAry = [[NSMutableArray alloc] init];
for(NSString *_string in _StringAry)
{
NSCharacterSet *charSet = [NSCharacterSet characterSetWithCharactersInString:#"_0123456789"];
_string = [[_string componentsSeparatedByCharactersInSet:charSet] componentsJoinedByString:#""];
[tmpAry addObject: [[_string copy] autorelease]];
}
NSLog(#"%#", tmpAry); // Gives the modified array
[tmpAry release];

How to remove the junk characters from string in aes128 decryption [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
The problem is encryption in server side they are using ISO10126d2Padding and decryption is happening but after decryption it is showing some junk values anyone please help remove that :
ACTUAL RESULT = india ismy
*DECRYPTED VALUE = India ismyg~²t
I will not say that this is the best way to remove unwanted characters from NSString but i did this ... and it is great.
NSString * str = #"your string";
NSMutableString * newString;
int j = [str length];
for (int i=0; i<j; i++) {
if (([str characterAtIndex:i] >=65 && [str characterAtIndex:i] <=90) || ([str characterAtIndex:i] >=97 && [str characterAtIndex:i] <=122) ||[str characterAtIndex:i] == 32 ) {
[newString appendFormat:#"%c",[str characterAtIndex:i]];
}
}
//([str characterAtIndex:i] >=65 && [str characterAtIndex:i] <=90) this is ASCII limit for A-Z
//([str characterAtIndex:i] >=97 && [str characterAtIndex:i] <=122) this is ASCII limit for a-z
//and [str characterAtIndex:i] == 32 is for space.
Now, print new string
NSLog(#"%#",newString);
let me know if it is woking for you!
Thank You!

how to get last updated value in sqlite3 [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
Hello Friends,
I have an application that will do the synchronization with the database to web-service. I have one table list in that I want to update, delete and insert the list. When the user click on the synchronization button I want to send the data which will be updated or changed in the database. The web-service are different for add, update or delete I want send only updated records.
For that what can I do for that any suggestion.
Thanks in advance,
Hardik Patel
You can maintain an extra column for timestamp.
So whenever a record is changed you should update the timestamp. (record_timestamp)
You have to maintain the time at which you have sent the data successfully to your server. (last_updated_timestamp)
So at the time of sync, you will send only those records to server whose
record_timestamp > last_updated_timestamp
The last_updated_timestamp will be updated every time successful sync is performed.
I hope this helps.
This link will help you compare time stamps in sqlite Timestamp comparison
You use sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*);
- (NSNumber *)executeSQL:(NSString *)sql withCallback:(void *)callbackFunction context:(id)contextObject {
NSString *path = [self pathToDB];
sqlite3 *db = NULL;
int rc = SQLITE_OK;
NSInteger lastRowId = 0;
rc = sqlite3_open([path UTF8String], &db);
if(SQLITE_OK != rc) {
NSLog(#"Can't open database: %s\n", sqlite3_errmsg(db));
sqlite3_close(db);
return nil;
}else {
char *zErrMsg = NULL;
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
rc = sqlite3_exec(db, [sql UTF8String], callbackFunction, (void*)contextObject, &zErrMsg);
if(SQLITE_OK != rc) {
NSLog(#"Can't run query '%#' error message: %s\n", sql, sqlite3_errmsg(db));
sqlite3_free(zErrMsg);
}
lastRowId = sqlite3_last_insert_rowid(db);
sqlite3_close(db);
[pool release];
}
NSNumber *lastInsertRowId = nil;
if(0 != lastRowId) {
lastInsertRowId = [NSNumber numberWithInteger:lastRowId];
}
return lastInsertRowId;
}

How enter in '.' first and then number in text of texfield? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I want enter float value in text field like as '.35'or '35' but not as '0..3678'.I want to restrict on enter of double dots. How do that?
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:
(NSRange)range replacementString:(NSString *)string{
NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
[numberFormatter setNumberStyle:NSNumberFormatterDecimalStyle];
NSNumber* myNumber;
NSString* myString = [textField.text stringByReplacingCharactersInRange:range withString:string];
range = NSMakeRange(0, [myString length]);
[numberFormatter getObjectValue:&myNumber forString:myString range:&range error:nil];
if (([myString length] > 0) && (myNumber== nil || range.length < [myString length])) {
return NO;
}else {
return YES;
}
}
I use above code for enter numeric value but it can't enter first dot/point and then number. What is error in above function?
int dots = 0;
for (int i = 0; i<[string length]; i++) {
char test = [string characterAtIndex:i];
if (test == '.') dots++;
}
if (dots > 1) {
return NO;
}
return YES;
Just check if the character is the first character, check if it is a dot, and if it is, pass 0. as the initial two characters in myString.