Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/43.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone XCode iOS中的错误SIGBART_Iphone_Ios_Objective C - Fatal编程技术网

Iphone XCode iOS中的错误SIGBART

Iphone XCode iOS中的错误SIGBART,iphone,ios,objective-c,Iphone,Ios,Objective C,我有一个包含不同组件的程序,但当我编译时,每次都会得到信号SIGBART。我的代码的主要目的是在用户移动时更改布尔值,在点击按钮时将文本设置为变量,并通过按不同的按钮将字符串设置为do/do/do。我的代码如下: ViewController.m #import "ViewController.h" @interface ViewController () @end @implementation ViewController @synthesize mapView; @synthesiz

我有一个包含不同组件的程序,但当我编译时,每次都会得到信号SIGBART。我的代码的主要目的是在用户移动时更改布尔值,在点击按钮时将文本设置为变量,并通过按不同的按钮将字符串设置为do/do/do。我的代码如下:

ViewController.m

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController
@synthesize mapView;
@synthesize dodont;
@synthesize reminders;

- (void)viewDidLoad
{
    [super viewDidLoad];
    mapView.showsUserLocation = YES;
    on = @"don't";
    dodont.text = on;
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)mapView:(MKMapView *)mapView
didUpdateUserLocation:
(MKUserLocation *)userLocation
{
    move = TRUE;
}

- (IBAction)enable:(id)sender {
    on = @"do";
}

- (IBAction)disable:(id)sender {
    on = @"don't";
}
- (IBAction)save:(id)sender {
    content = reminders.text;
}
@end
ViewController.h

#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>

NSString *on;
BOOL move= FALSE;
NSString *content;

@interface ViewController : UIViewController {
    MKMapView *mapview;
}
@property (weak, nonatomic) IBOutlet MKMapView *mapView;

- (IBAction)enable:(id)sender;

- (IBAction)disable:(id)sender;
@property (weak, nonatomic) IBOutlet UILabel *dodont;
- (IBAction)save:(id)sender;
@property (strong, nonatomic) IBOutlet UITextView *reminders;

@end
AppDelegate.h

#import <UIKit/UIKit.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;

@end
#导入
@接口AppDelegate:UIResponder
@属性(强,非原子)UIWindow*window;
@结束

你不想把这些东西放进去吗:

NSString *on;
BOOL move= FALSE;
NSString *content;
在.h文件中的
@interface
@end
之间

不要忘记:每个属性的
@property(非原子,强)
(BOOL值没有强参数)

您的界面应如下所示:

#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>

@interface ViewController : UIViewController {
    MKMapView *mapview;
}

@property (strong, nonatomic) NSString *on;
@property (nonatomic) BOOL move;
@property (strong, nonatomic) NSString *content;
@property (weak, nonatomic) IBOutlet MKMapView *mapView;
@property (strong, nonatomic) IBOutlet UITextView *reminders;
@property (weak, nonatomic) IBOutlet UILabel *dodont;

- (IBAction)enable:(id)sender;    
- (IBAction)disable:(id)sender;
- (IBAction)save:(id)sender;

@end
#导入
#进口
@界面ViewController:UIViewController{
MKMapView*mapview;
}
@属性(强,非原子)NSString*on;
@属性(非原子)布尔移动;
@属性(强,非原子)NSString*内容;
@属性(弱,非原子)IBMMapView*mapView;
@属性(强、非原子)IBOutlet UITextView*提醒;
@性质(弱、非原子)IBUILabel*dodont;
-(iAction)启用:(id)发送方;
-(iAction)禁用:(id)发送方;
-(iAction)保存:(id)发送方;
@结束

在iOS/Objective-C中,变量的声明方式如下所示:

@接口类名:超类

{

  • #在这里声明变量
}

  • 在此处设置变量的属性
  • 在此声明方法
@结束

您正在类声明上方声明变量


此外,您还没有在ApplicationIDFinishLaunching方法中初始化应用程序的窗口。尝试此操作,并使用要加载的视图设置窗口rootviewcontroller。

在代码中的什么位置出现了
SIGABRT
?这些是全局的,这应该是一个注释。因此,您做得不对。我仍然得到sigbartuiapplicationmain(argc、argv、nil、NSStringFromClass([AppDelegate类]);我更改了变量声明并对其进行了简化,我将把新代码粘贴到paste Bin上,我想他使用了故事板。。所以这无关紧要。
#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>

@interface ViewController : UIViewController {
    MKMapView *mapview;
}

@property (strong, nonatomic) NSString *on;
@property (nonatomic) BOOL move;
@property (strong, nonatomic) NSString *content;
@property (weak, nonatomic) IBOutlet MKMapView *mapView;
@property (strong, nonatomic) IBOutlet UITextView *reminders;
@property (weak, nonatomic) IBOutlet UILabel *dodont;

- (IBAction)enable:(id)sender;    
- (IBAction)disable:(id)sender;
- (IBAction)save:(id)sender;

@end