Tuesday, September 25, 2012

Read data from document directory Folder


   
        NSString * resourcePath = [[NSBundle mainBundle] resourcePath];
        NSString * documentsPath = [resourcePath stringByAppendingPathComponent:@"Folder_Name"];
        NSError * error;
        NSArray *contentarr = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:documentsPath error:&error];

Monday, September 24, 2012

Steps to analyze crash report from apple


  1. Copy the release .app file which was pushed to the appstore, the .dSYM file that was created at the time of release and the crash report receive from APPLE into a FOLDER.
  2. OPEN terminal application and go to the folder created above (using CD command)
  3. atos -arch armv7 -o YOURAPP.app/YOURAPP MEMORY_LOCATION_OF_CRASH. The memory location should be the one at which the app crashed as per the report.
Ex: atos -arch armv7 -o 'app name.app'/'app name' 0x0003b508
This would show you the exact line, method name which resulted in crash.
Ex: [classname functionName:]; -510
Symbolicating IPA
if we use IPA for symbolicating - just rename the extention .ipa with .zip , extract it then we can get a Payload Folder which contain app. In this case we don't need .dSYM file.

Sunday, September 23, 2012

Validate textfield for number input




- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
    static NSCharacterSet *charSet = nil;
    if(!charSet) {
        charSet = [[[NSCharacterSet characterSetWithCharactersInString:@"0123456789."] invertedSet] retain];
    }
    NSRange location = [string rangeOfCharacterFromSet:charSet];
    return (location.location == NSNotFound);
}

set image and textcolur to navigation item



self.navigationController.navigationBarHidden = NO;
    
    UIImage *image = [UIImage imageNamed: @"nav_bar.png"];
    [self.navigationController.navigationBar setBackgroundImage:image forBarMetrics:UIBarMetricsDefault];
    
    
    UILabel *label = [[[UILabel alloc] initWithFrame:CGRectZero] autorelease];
    label.backgroundColor = [UIColor clearColor];
    label.font = [UIFont boldSystemFontOfSize:16.0];
    label.shadowColor = [UIColor colorWithWhite:0.0 alpha:0.0];
    label.textAlignment = UITextAlignmentCenter;
    label.textColor = [UIColor blackColor]; // change this color
    self.navigationItem.titleView = label;
    label.text = NSLocalizedString(@"Services", @"");
    [label sizeToFit];

calculate EMI In Objective - C


- (CGFloat)calculateEmi{
    CGFloat loanAmt =[[loanAmountTxt text]floatValue];
    CGFloat tenure =[[loanTenureTxt text]floatValue];
    CGFloat InterestRateReducing = [[IntRateTxt text]floatValue];
    CGFloat r = InterestRateReducing/12/100;
    
    CGFloat emi = (loanAmt * r)*(pow((1+r), tenure)/((pow((1+r), tenure)-1)));
    NSLog(@"emi value...%f",emi);

    return emi;
}