1

我是 xcode 4.5 的新手

我正在开发一个应用程序,它因运行时错误 SIGABRT而停止。

这是 main.m 文件中发生错误的代码...

// ***********************************************************
//  main.m
//  ex21
//

#import <UIKit/UIKit.h>

#import "ex21AppDelegate.h"

int main(int argc, char *argv[])
{
    @autoreleasepool {
        return UIApplicationMain(argc, argv, nil, NSStringFromClass([ex21AppDelegate class]));

        //Login *login1 = [[Login alloc]init];
        //[login1 setLoginid:@"Sam"];
        //[login1 setPassword:ca@"test1"];
        //NSLog(@"Login ID = %@, Password = %@",[login1 loginid], [login1 password]);

        return UIApplicationMain(argc, argv, nil, NSStringFromClass([ex21AppDelegate class]));

    }
}


// ***********************************************************
//  ex21AppDelegate.h
//  ex21
//

#import <UIKit/UIKit.h>

@interface ex21AppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;

@end


// ***********************************************************
//  ex21AppDelegate.m
//  ex21
//

#import "ex21AppDelegate.h"

@implementation ex21AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.
    return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application
{
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application
{
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application
{
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application
{
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application
{
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end


// ***********************************************************
//  ex21MainMenu.h
//  ex21
//

#import <UIKit/UIKit.h>

@interface ex21MainMenu : UIView {

}

-(IBAction)hyperlink;

@end


// ***********************************************************
//
//  ex21MainMenu.m
//  ex21
//

#import "ex21MainMenu.h"

@implementation ex21MainMenu

- (IBAction)hyperlink {
    [[UIApplication sharedApplication]openURL:[NSURL URLWithString:@"http://www.google.com"]];

}

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
    }
    return self;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/

@end



// ***********************************************************
//  ex21ViewController.h
//  ex21
//

#import <UIKit/UIKit.h>

@interface ex21ViewController:  UITableViewController

@end


// ***********************************************************
//  ex21ViewController.m
//  ex21
//

#import "ex21ViewController.h"

@interface ex21ViewController ()

@end

@implementation ex21ViewController

- (IBAction)doneWithKeyboard:(id)sender {
    [sender resignFirstResponder];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}

@end

我阻止上面的代码导入下面的代码,因为我决定不使用它。

// ***********************************************************
//  Login.h
//  ex21
//

#import <Foundation/Foundation.h>

@interface Login : NSObject

@property (nonatomic, strong) NSString *loginid;
@property (nonatomic, strong) NSString *password;

- (id)initWithLoginID:(NSString *)loginid
             password:(NSString *)password;
@end

// ***********************************************************
//  Login.m
//  ex21
//

#import "Login.h"

@implementation Login

@synthesize loginid = _loginid;
@synthesize password = _password;

- (id)initWithLoginID:(NSString *)loginid
             password:(NSString *)password
{
    self = [super init];
    if (self != nil){
        _loginid = loginid;
        _password = password;
    }
    return self;
}
@end

========================================

异常状态寄存器指出以下内容:

  • rapno(无符号整数)
  • 错误(无符号整数)
  • faultvaddr(无符号整数)

有谁知道发生了什么?

4

0 回答 0