This has been annoying me for a good week, as i have previously used MBProgressHUD in prior versions of the app.
No matter how I try to set the code in my project to show MBProgressHUD, I always receive 'Apple Mach-O Linker Error':"Undefined symbols for architecture i386: "_OBJC_CLASS_$_MBProgressHUD", referenced from: objc-class-ref in Home.o ld: symbol(s) not found for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation)"
Below is the source code I'm using in my application m file:
#import "AppDelegate.h"
#import "Home.h"
#import "SSFB.h"
#import "SST.h"
@implementation AppDelegate
@synthesize window = _window;
@synthesize tabBarController = _tabBarController;
@synthesize navigationController = _navigationController;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions: (NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
UIViewController *home = [[Home alloc] initWithNibName:@"Home" bundle:nil];
UIViewController *ssfb = [[SSFB alloc] initWithNibName:@"SSFB" bundle:nil];
UIViewController *sst = [[SST alloc] initWithNibName:@"SST" bundle:nil];
self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = @[home, ssfb, sst];
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
return YES;
}
@end
Home.h
#import <UIKit/UIKit.h>
#import "MBProgressHUD.h"
@interface Home : UIViewController <UIWebViewDelegate>{
IBOutlet UIWebView *homeWebView;
IBOutlet UINavigationBar *homeNavBar;
UIAlertView *loadingAlert;
UIActivityIndicatorView *loadingTicker;
MBProgressHUD *HUD;
}
@property (retain, nonatomic) IBOutlet UINavigationBar *homeNavBar;
@property (retain, nonatomic) UIAlertView *loadingAlert;
@property (retain, nonatomic) UIAlertView *loadingTicker;
-(IBAction)refreshhomeWebView:(id)sender;
-(void)myTask;
-(void)showWithLabel;
@end
And finally the Home.m file:
@implementation Home
@synthesize homeNavBar = _homeNavBar, loadingAlert, loadingTicker = _loadingTicker;
-(void)myTask{
while(homeWebView.loading){
}
}
- (void)showWithLabel {
HUD = [[MBProgressHUD alloc] initWithView:self.navigationController.view];
[self.navigationController.view addSubview:HUD];
HUD.delegate = self;
HUD.labelText = @"Loading";
[HUD showWhileExecuting:@selector(myTask) onTarget:self withObject:nil animated:YES];
}
-(void)webView:(UIWebView *)homeWebView didFailLoadWithError:(NSError *)error{
NSLog(@"error");
if ([error code] == -1009 || [[error localizedDescription] isEqualToString:@"no Internet connection"]){
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"There is currently no internet access." delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
[alert show];
}
if ([error code] == -1001 || [[error localizedDescription] isEqualToString:@"timed out"]){
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"The connection, please try again." delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
[alert show];
}
if ([error code] == -1004 || [[error localizedDescription] isEqualToString:@"can't connect to host"]){
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Can not connect to the webpage's host at this time, please try again later." delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
[alert show];
}
else{
}
}
-(void)webViewDidStartLoad:(UIWebView *)homeWebView{
[self showWithLabel];
NSLog(@"start load");
}
-(void)webViewDidFinishLoad:(UIWebView *)homeWebView{
}
-(IBAction)refreshhomeWebView:(id)sender{
[homeWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.socialstarsclub.com"] ]];
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
self.title = NSLocalizedString(@"Home", @"Home");
self.tabBarItem.image = [UIImage imageNamed:@"home_30"];
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
[self.homeNavBar setBarStyle:UIBarStyleBlackOpaque];
[homeWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.socialstarsclub.com"] ]];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
I've tried variations of code for 'showWithLable' trying to set the HUD on the highest view heir achy but always receive the same errors, can anyone see what could be a simple mistake in my coding?