Sunday, November 1, 2015

Colour-Memory 4*4 grid project

The goal of this work sample is to construct a sample memory game called ”Colour Memory”. The game board consists of a 4x4 grid with 8 pairs of color cards.

 Here is a list of things I used to create this sample.

1) Use of sqlite database  and interaction class 
2) subclassing of UITableViewCell
3) subclassing of UIButton
4) Use of Auto Layout in iOS


UIButton subclassing is used to store the state of that button
and used to store the image name that we need to set as a image when user taps on that button.
It also contain animation code of flip view from left to right and right to left.
Here is a code to flip the UIButton and show image.

You can find this code in below given link.
Name of the file is ColorUIButton
 -(void)showButtton  
 {  
 self.userInteractionEnabled = false;  
 [UIView transitionWithView:self duration:0.3 options:UIViewAnimationOptionTransitionFlipFromRight animations:^{  
 //code to change the image of UIButton  
 } completion:^(BOOL finished) {  
 self.userInteractionEnabled = true;  
 }];  
 }  







UITableViewCell is used to handle the row of 4 UIButtons
 It handle all the interaction done on UIButton.

You can find this code in below given link.
Name of the file is ColorCell


















Download full code from GitHub

Saturday, October 31, 2015

Twitter Integration in iOS

Twitter Integration using SLRequest 

 1) Ask user to access its twitter account

  ACAccountStore *accountStore = [[ACAccountStore alloc] init];  
   ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];  
   [accountStore requestAccessToAccountsWithType:accountType options:nil completion:^(BOOL granted, NSError *error) {  
     if(granted) {  
            //User allowed to access account  
     }}];  

2) Get all twitter accounts from list

 ACAccountStore *store = [[ACAccountStore alloc] init];  
   ACAccountType *AccountType = [store accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];  
  NSArray *accountsArray = [store accountsWithAccountType:AccountType];  

3)get particular Account from Accounts array.

 -(ACAccount *)getTwitterAccount:(NSString *)aStrUserName  
 {  
   ACAccountStore *store = [[ACAccountStore alloc] init];  
   ACAccountType *AccountType = [store accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];  
   __weak ACAccount *selAccount = nil;  
   NSArray *accountsArray = [store accountsWithAccountType:AccountType];  
   for (ACAccount *myaccount in accountsArray) {  
     if([myaccount.username.lowercaseString isEqualToString:aStrUserName.lowercaseString])  
     {  
       selAccount = myaccount;  
       break;  
     }  
   }  
   return selAccount;  
 }