- (NSString *)getTabBarTitle:(NSInteger)index{
NSString *ret = nil;
if(index > -1){
NSInteger tsize = [self.tbc count];
if(index < tsize){
NSDictionary *dict = (NSDictionary *)[tbc objectAtIndex:index];
ret = (NSString *)[dict objectForKey:@"tbtitle"];
}
}
return ret;
}
- (NSString *)getTabBarIconPath:(NSInteger)index{
NSString *ret = nil;
if(index > -1){
NSInteger tsize = [self.tbc count];
if(index < tsize){
NSDictionary *dict = (NSDictionary *)[tbc objectAtIndex:index];
ret = (NSString *)[dict objectForKey:@"tbicon"];
NSBundle *mainBundle = [NSBundle mainBundle];
ret = [mainBundle pathForResource:ret ofType:@"png"];
}
}
return ret;
}
- (NSString *)getTabBarViewURL:(NSInteger)index{
NSString *ret = nil;
if(index > -1){
NSInteger tsize = [self.tbc count];
if(index < tsize){
NSDictionary *dict = (NSDictionary *)[tbc objectAtIndex:index];
ret = (NSString *)[dict objectForKey:@"tburl"];
if(ret != nil){
if ([ret hasPrefix:@"locbundle://"]) {
NSString *str = [ret substringFromIndex:[@"locbundle://" length]];
//NSLog(@"sub url is %@",str);
NSBundle *mainBundle = [NSBundle mainBundle];
NSArray *pcs = [str pathComponents];
if(pcs != nil){
// NSInteger len = [pcs count];
NSString *fp = [str lastPathComponent];
NSRange range = [fp rangeOfString:@"."];
NSString *fn = nil;
NSString *fe = [str pathExtension];
if(range.location != NSNotFound) {
fn = [fp substringToIndex:range.location];
}
range = [str rangeOfString:fn];
NSString *p = nil;
if(range.location != NSNotFound){
p = [str substringToIndex:range.location];
}
if(p != nil && fn != nil && fe != nil){
NSInteger pl = [p length];
if(pl > 1){
if([p hasSuffix:@"/"]){
p = [p substringToIndex:(pl - 1)];
}
}
ret = [mainBundle pathForResource:fn ofType:fe inDirectory:p];
}else if(fn != nil && fe != nil){
ret = [mainBundle pathForResource:fn ofType:fe];
}
if (ret != nil) {
NSURL *u = [NSURL fileURLWithPath:ret];
ret = [u absoluteString];
}
}
}
}
}
}
return ret;
}
- (NSInteger)getTabBarItemNumber{
return [self.tbc count];
}
- (void)netRefInc{
UIApplication *app = [UIApplication sharedApplication];
BOOL bv = app.networkActivityIndicatorVisible;
netref++;
if(!bv){
app.networkActivityIndicatorVisible = YES;
}
}
- (void)netRefDec{
UIApplication *app = [UIApplication sharedApplication];
if(netref > 0){
netref--;
if (netref == 0) {
app.networkActivityIndicatorVisible = NO;
}
}else{
app.networkActivityIndicatorVisible = NO;
}
}
- (void)dealloc{
[csurl release];
[tbc release];
[super dealloc];
}