Wednesday, 28 August 2013

Exclude subview to be tapped

-(void) gestureTap:(UITapGestureRecognizer *)sender 
    CGPoint point = [sender locationInView:sender.view];
    UIView *dontTouchView = [sender.view hitTest:point withEvent:nil];
    if ([dontTouchView isKindOfClass:[UIImageView class]]) 
{  // Do whatever u want
    } else 
     // Do whatever u want 


Monday, 26 August 2013

Delete document directory all data

- (void)delete_document_directory_all_data 
NSString *dirPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
NSFileManagerfilemanager = [[NSFileManager alloc] init];
NSDirectoryEnumeratordet = [filemanager enumeratorAtPath: dirPath];
NSErrorerror = nil;
BOOL deletePath;
NSString* file;
while (file = [det nextObject])
        deletePath = [filemanager removeItemAtPath:[dirPath stringByAppendingPathComponent:file] error:& error];
if (! deletePath && error)
            {NSLog(@"error  : %@"error);}


Search specific string from a NSArray objective C

BOOL string = [yourArray containsObject: @"find string"];            //for specific string

NSUInteger forIndex = [yourArray indexOfObject: @"find string"]; //for index of object

Friday, 23 August 2013

Local Database using Plist in ios

 NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSString *path = [documentsDirectory stringByAppendingPathComponent:@"plist.plist"];
    NSFileManager *fileManager = [NSFileManager defaultManager];
    NSMutableArray *array = [[NSMutableArray alloc] init];
    if (![fileManager fileExistsAtPath: path])
        [array addObject:1];
        [array writeToFile: [documentsDirectory stringByAppendingPathComponent:@"plist.plist"] atomically:YES];
        [array addObjectsFromArray:[NSArray arrayWithContentsOfFile:path]];
        [array addObject:2];
        [array writeToFile: [documentsDirectory stringByAppendingPathComponent:@"plist.plist"] atomically:YES];


Wednesday, 14 August 2013

To call a function repeatedly at particular interval in Objective C.

[NSTimer scheduledTimerWithTimeInterval: 2.0 target: self
                                                      selector: @selector(yourMethod) userInfo: nil repeats: YES]; 

Monday, 12 August 2013

IOS 6 if autorotate not worked.

//Put this line code in your code

- (NSUInteger)supportedInterfaceOrientations
    return UIInterfaceOrientationMaskAll;


Wednesday, 7 August 2013

Rain in cocos2d

        CCParticleRain* part=[CCParticleRain node];
        part.texture=[[CCTextureCache sharedTextureCache] addImage:@"heal.png"];
        part.position=ccp(500, 750);

        [self addChild:part];

//add a png of a particle as named above heal.png