Powered By Blogger

Monday, August 16, 2010

PLIST implementation

-(void)createAcceptPList{
    NSMutableArray *acceptArray = [NSMutableArray arrayWithCapacity:1];
    NSString *path=[self getPathForAcceptList];
   
    // Create a person and add them to the array
    [acceptArray addObject:[NSNumber numberWithInt:0]];
   
    [acceptArray writeToFile:path atomically:YES];
}
-(NSString *)getPathForAcceptList{
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    return [documentsDirectory stringByAppendingPathComponent:@"accept.plist"];
}
-(int)readFromAcceptList{
    NSString *path=[self getPathForAcceptList];
   
    NSMutableArray *acceptArray=[NSMutableArray arrayWithContentsOfFile:path];
   
    if([acceptArray count]>0)
    {
        NSNumber *number1=[acceptArray objectAtIndex:0];
        return [number1 intValue];
    }
    else
    {
        return -1;
    }
}
-(BOOL)readFromInfoList{
    BOOL bSuccess=FALSE;
    NSBundle *mainBundle = [NSBundle mainBundle];
    NSString *value = [mainBundle objectForInfoDictionaryKey:@"SignerIdentity"];
   
    if([[value lowercaseString] isEqualToString:@"apple iphone os application signing"])
    {
        bSuccess = TRUE;
    }
    return bSuccess;
}
-(NSString *)getPathForApplyList{
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    return [documentsDirectory stringByAppendingPathComponent:@"apply.plist"];
}
-(int)readFromApplyList{
    NSString *path=[self getPathForApplyList];
   
    NSMutableArray *applyArray=[NSMutableArray arrayWithContentsOfFile:path];
   
    if([applyArray count]>0)
    {
        NSNumber *number1=[applyArray objectAtIndex:0];
        return [number1 intValue];
    }
    else
    {
        return -1;
    }
}

No comments:

Post a Comment