我无法解决那个 ARC 问题。
详细错误消息是“初始化方法必须返回与接收器类型相关的类型”
@property (nonatomic, strong) NSString *initURL;
此代码行有错误问题。
我添加了 .h 和 .m 文件。
请帮我 :)
xcode5, IOS
//
// MFTabBarController.h
// ELandMobileFramework
//
// Created by Kim DongGeun on 12. 2. 23..
// Copyright (c) 2012년 purpleworks. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface MFTabBarController : UITabBarController <UITabBarControllerDelegate, UINavigationControllerDelegate> {
NSString *initURL;
}
@property (nonatomic, strong) NSString *initURL;
- (id)init;
- (void)initSelectedIndexWithInitURL:(NSString *)url;
//- (void)setInitURL:(NSString *)initURL;
@end
//
// MFTabBarController.m
// ELandMobileFramework
//
// Created by Kim DongGeun on 12. 2. 23..
// Copyright (c) 2012년 purpleworks. All rights reserved.
//
#import "MFTabBarController.h"
#import "MFSettingHelper.h"
#import "MFUrlRoute.h"
#import "MFUrlHelper.h"
#import "MFAppDelegate.h"
#import "MFAccountSqlite.h"
#import "MFRootViewController.h"
#import "MFSettingViewController.h"
#import "MFRootNavigationController.h"
@interface MFTabBarController()
- (void)initViewControllers;
@end
@implementation MFTabBarController
@synthesize initURL = _initURL;
- (id)init
{
self = [super init];
if (self) {
[self initViewControllers];
}
return self;
}
//-(id) initURL:(NSString *)initUrl
//{
// if (self = [super init]) {
// //do stuff
// _initURL = (NSString *)init;
//
// }
// return self;
//}
- (void)initViewControllers
{
// view controller array
NSMutableArray *tabViewControllers = [[NSMutableArray alloc] initWithCapacity:0];
// root view nibname
NSString *nibName = [MFSettingHelper getValue:@"RootViewClassName"];
if([nibName isEqualToString:@"MFRootViewController"]) {
nibName = [NSString stringWithFormat:@"ELandMobileFrameworkResource.bundle/%@", nibName];
}
/*
// get menu list
NSManagedObjectContext *context = [(MFAppDelegate *)[[UIApplication sharedApplication] delegate] managedObjectContext];
NSError *error;
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription *menuEntity = [NSEntityDescription entityForName:@"MenuSection"
inManagedObjectContext:context];
[fetchRequest setEntity:menuEntity];
NSMutableArray *menus = [[context executeFetchRequest:fetchRequest error:&error] mutableCopy];
*/
MFAccountSqlite *accountSqlite = [[MFAccountSqlite alloc] init];
NSMutableArray *menus = [[NSMutableArray alloc] initWithArray:[accountSqlite getMenuSections]];
for (int i=0; i < [menus count]; i++) {
MFMenuSectionModel *sectionModel = (MFMenuSectionModel *)[menus objectAtIndex:i];
for (int j=0; j <[[sectionModel menus] count]; j++) {
MFMenuModel *menu = [[sectionModel menus] objectAtIndex:j];
MFUrlRoute *route = [[MFUrlRoute alloc] initWithUrl:menu.url];
if([route equal:@"webview" action:@"loadUrl"] == YES) {
MFRootViewController *rootViewController = [[NSClassFromString([MFSettingHelper getValue:@"RootViewClassName"]) alloc] initWithNibName:nibName bundle:nil];
MFRootNavigationController *navigationController = [[MFRootNavigationController alloc] initWithRootViewController:rootViewController];
[navigationController setOrientation:[MFSettingHelper getValue:@"Orientation" defaultValue:@"portrait"]];
[tabViewControllers addObject:navigationController];
}
}
}
// setting view
MFSettingViewController *settingViewController = [[MFSettingViewController alloc] init];
MFRootNavigationController *navigationController = [[MFRootNavigationController alloc] initWithRootViewController:settingViewController];
[navigationController setOrientation:[MFSettingHelper getValue:@"Orientation" defaultValue:@"portrait"]];
[tabViewControllers addObject:navigationController];
[self setViewControllers:tabViewControllers];
// update tab style
int tabCount = 0;
for (int i=0; i < [menus count]; i++) {
MFMenuSectionModel *sectionModel = (MFMenuSectionModel *)[menus objectAtIndex:i];
for (int j=0; j <[[sectionModel menus] count]; j++) {
MFMenuModel *menu = [[sectionModel menus] objectAtIndex:j];
MFUrlRoute *route = [[MFUrlRoute alloc] initWithUrl:menu.url];
if([route equal:@"webview" action:@"loadUrl"] == YES) {
[[[[self viewControllers] objectAtIndex:tabCount] tabBarItem] setTitle:menu.name];
if([menu.icon hasPrefix:@"http://"]) {
[[[[self viewControllers] objectAtIndex:tabCount] tabBarItem] setImage:[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:menu.icon]]]];
} else {
[[[[self viewControllers] objectAtIndex:tabCount] tabBarItem] setImage:[UIImage imageNamed:menu.icon]];
}
[[[[[self viewControllers] objectAtIndex:tabCount] viewControllers] objectAtIndex:0] setDefaultURL:[MFUrlHelper getFullUrl:[route.params objectForKey:@"url"]]];
[[[[[self viewControllers] objectAtIndex:tabCount] viewControllers] objectAtIndex:0] setTitle:menu.name];
if (![menu.badge isEqualToString:@""] && tabCount < 4) {
[[[[self tabBar] items] objectAtIndex:tabCount] setBadgeValue:menu.badge];
}
if ([menu.url isEqualToString:initURL]) {
[self setSelectedIndex:tabCount];
}
tabCount++;
}
}
}
self.moreNavigationController.delegate = self;
}
- (void)initSelectedIndexWithInitURL:(NSString *)url
{
if (url) {
[self setInitURL:url];
}
[self initViewControllers];
}
#pragma mark - navigationController Delegate
- (void)navigationController: (UINavigationController *)navigationController
willShowViewController: (UIViewController *)viewController
animated: (BOOL)animated {
UINavigationBar* morenavbar = navigationController.navigationBar;
UINavigationItem* morenavitem = morenavbar.topItem;
morenavitem.rightBarButtonItem = nil;
}
@end