Program received signal: “EXC_BAD_ACCESS”.
(gdb) bt
#0 0x30011940 in objc_msgSend ()
#1 0x30235f24 in CFRelease ()
#2 0x308f497c in -[UIImage dealloc] ()
#3 0x30236b78 in -[NSObject release] ()
#4 0x30a002a0 in FlushNamedImage ()
#5 0x30250a26 in CFDictionaryApplyFunction ()
#6 0x30a001a4 in _UISharedImageFlushAll ()
#7 0x30a00738 in +[UIImage(UIImageInternal) _flushCacheOnMemoryWarning:] ()
#8 0x3054dc80 in _nsnote_callback ()
#9 0x3024ea58 in _CFXNotificationPostNotification ()
#10 0x3054b85a in -[NSNotificationCenter postNotificationName:object:userInfo:] ()
#11 0x3054dbc0 in -[NSNotificationCenter postNotificationName:object:] ()
#12 0x30a00710 in -[UIApplication _performMemoryWarning] ()
#13 0x30a006a8 in …Run Code Online (Sandbox Code Playgroud) 当我的应用程序到达此时,我收到EXC_BAD_ACCESS
NSString *nameData = nameTextField.text;
NSString *emailData= emailTextField.text;
NSString *phoneData = phoneTextField.text;
NSString *serviceData = serviceTextView.text;
NSString *post = [NSString stringWithFormat:@"email_address=&contents=&form_identifier=538b7271-df83-41f5-84b0-db0fed518ade&form_type=1&empty_form_msg=Please%20fill%20in%20something%20before%20submitting.&1_1_10_40_First%2BName=%@&2_1_20_30_Last%2BName=&3_1_25_25_Company=&4_1_30_999_Email=%@&5_1_40_10_Phone=%@&6_1_50_0_Address%2B1=&7_1_60_-10_Address%2B2=&8_1_70_-20_City=&9_3_80_-30_County=&10_3_90_-40_Postcode=&11_2_100_-50_Comments=%@&submit=Send",nameData,emailData,phoneData,serviceData];
Run Code Online (Sandbox Code Playgroud)
这是因为这个字符串中的数据太长了吗?
这里的代码:
- (void)addAnswerWithNumber:(NSString *)numberAnswer
{
UIButton *aButton = [[UIButton buttonWithType:UIButtonTypeCustom] retain];
[aButton setBackgroundImage:[UIImage imageNamed:@"roundBlue.png"] forState:UIControlStateNormal];
[aButton addTarget:self action:@selector(removeAnswer:) forControlEvents:UIControlEventTouchUpInside];
[aButton setTitle:numberAnswer forState:UIControlStateNormal];
aButton.enabled = YES;
aButton.titleLabel.font = [UIFont fontWithName:@"HelveticaNeue-Bold" size:18.0];
aButton.titleLabel.textColor = [UIColor whiteColor];
aButton.titleLabel.textAlignment = UITextAlignmentCenter;
[dropableZone addSubview:aButton];
[buttonList addObject:aButton];
[aButton release];
[aButton release];
if ([buttonList count] > 0) {
dropHereLabel.text = @"";
[self repositionRoundButton];
}else
{
dropHereLabel.text = @"Déposez votre ou vos Réponse(s) ici";
}
}
- (void)repositionRoundButton
{
int yPos = ((890 / 2) - (([buttonList count] …Run Code Online (Sandbox Code Playgroud) EXC_BAD_ACCESS我编写了一个 Cocoa 应用程序,当我关闭应用程序窗口时出现错误。我读到这个错误通常意味着内存问题,但我已经ARC mode打开并且不需要关心释放等(xCode 禁止我调用这个函数并自动管理内存)。
错误指向return NSApplicationMain(argc, (const char **)argv);主函数中的行。
这是我的应用程序的代码:
.h 文件:
@interface MainDreamer : NSWindow <NSWindowDelegate>
{
NSTextField *dreamField;
NSTableView *dreamTable;
NSImageView *dreamview;
NSMutableArray *dreamlist;
NSMutableArray *dataset;
}
@property (nonatomic, retain) IBOutlet NSTextField *dreamField;
@property (nonatomic, retain) IBOutlet NSTableView *dreamTable;
@property (nonatomic, retain) IBOutlet NSImageView *dreamview;
@property (nonatomic, retain) IBOutlet NSMutableArray *dreamlist;
@property (nonatomic, retain) IBOutlet NSMutableArray *dataset;
@property (assign) IBOutlet NSWindow *window;
@end
Run Code Online (Sandbox Code Playgroud)
.m 文件:
@implementation MainDreamer
@synthesize window;
@synthesize dataset;
@synthesize …Run Code Online (Sandbox Code Playgroud) 我创建了一个从普通字符串生成属性字符串的方法.在attrString低于价值是它的内容非空和正确的.
在运行我的应用程序时,第二行失败了EXC_BAD_ACCESS.知道为什么吗?
该__bridge_retained呼叫是iOS 5的要求.我也试过,__bridge但没有效果,问题仍然存在.
NSMutableAttributedString *attrString = (NSMutableAttributedString*)[textLayer attributedString];
CTFramesetterRef framesetter = CTFramesetterCreateWithAttributedString((__bridge_retained CFMutableAttributedStringRef)attrString);
Run Code Online (Sandbox Code Playgroud)
UPDATE
如果我做:
NSMutableAttributedString *attrString = (NSMutableAttributedString*)[textLayer attributedString];
NSLog(@"%@", attrString);
CTFramesetterRef framesetter = CTFramesetterCreateWithAttributedString((__bridge CFMutableAttributedStringRef)attrString);
Run Code Online (Sandbox Code Playgroud)
然后该NSLog行将无法编译; Xcode给出了警告和错误说明"Incompatible pointer types passing 'char[3]' to parameter of type 'NSString *'".
所以我尝试了这个:
NSLog([attrString description]);
Run Code Online (Sandbox Code Playgroud)
这给出了以下输出(我用<snipped>隐私替换了字符串内容):
2012-01-19 06:49:11.307 WritePath[2475:707] <Snipped>
{
CTForegroundColor = "<CGColor 0x281530> [<CGColorSpace 0x22d1a0> (kCGColorSpaceDeviceRGB)] ( 0 0 0 1 )"; …
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
@try {
if ([segue.identifier isEqualToString:@"taskListSegue"])
{
MindMapInformationViewController_iPhone *taskListContentController = [segue destinationViewController];
int selectedIndexPath = [[self.tableView indexPathForSelectedRow] row];
MindMap *newMindMap;
newMindMap = [mindmaps objectAtIndex:selectedIndexPath];
FileManager *fileManager = [[[FileManager alloc] init] autorelease];
[fileManager readFile:newMindMap.pathToMindmapAtDevice parsing:YES];
NSMutableArray *taskArray = [fileManager getArray];
[taskListContentController setTasksOfSelectedMindmap:taskArray];
}
}
@catch (NSException *exception) {
}
}
-(void)setTasksOfSelectedMindmap:(NSMutableArray *)tasks {
@try {
[self initComponents];
if (tasks != nil) {
taskArray = tasks;
}
}
@catch (NSException *exception) {
}
}
-(void)initComponents {
@try { …Run Code Online (Sandbox Code Playgroud) 我有以下方法来更新显示简单时间的标签
-(void)updateTimeLabel:(NSTimer *)timer{
NSInteger secondsSinceStart = (NSInteger)[[NSDate date] timeIntervalSinceDate:_startTime];
NSInteger seconds = secondsSinceStart % 60;
NSInteger minutes = (secondsSinceStart / 60) % 60;
NSInteger hours = secondsSinceStart / (60 * 60);
NSString *result = nil;
if (hours > 0) {
result = [NSString stringWithFormat:@"%02d:%02d:%02d", hours, minutes, seconds];
}
else {
result = [NSString stringWithFormat:@"%02d:%02d", minutes, seconds];
}
_totalTime = result;
_totalTimeLabel.text = result;
}
Run Code Online (Sandbox Code Playgroud)
然后我将其称为按钮操作:
-(IBAction) startTimer{
_startTime = [NSDate date];
_walkRouteTimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(updateTimeLabel:) userInfo:nil repeats:YES];
[_walkRouteTimer …Run Code Online (Sandbox Code Playgroud) 程序在运行时崩溃了。当我的代码到达 NSMutableArray 时,我使用arryWithObjects方法在其中保存了一些对象,这里是我的代码
(NSMutableArray *) NumSysToNumSysMultiplyMetd:(NSString *)DecCode lenthOfDecCode
:(int)length NumSysMultiplyValue
:(int)value
{
NSString * step1 = DecCode;
int Step2 = 0;
NSString *step2s=@"=> ";
int finalAnswer=0;
for (int i=length,j=0; i >=0; i--,j++)
{
NSString *digit;
digit = [NSString stringWithFormat:@"%c",[DecCode characterAtIndex:j]];
step1 = [step1 stringByAppendingString: [NSString stringWithFormat:@"%@ * %i^%i + ",digit,value,i]];
Step2= [digit integerValue] * pow(value, i);
step2s= [step2s stringByAppendingString:[NSString stringWithFormat:@" %i +",Step2]];
finalAnswer =finalAnswer + Step2;
}
NSMutableArray *mut = [NSMutableArray arrayWithObjects:step1,step2s,finalAnswer,nil];
return mut
Run Code Online (Sandbox Code Playgroud) 我有以下代码:
// Get the matches
var recipieMatches = queryResults[MATCHES_INDEX] as Array<Dictionary<String, AnyObject>>
// Set some global vars
var numberOfRecipiesToDisplay: Int = recipieMatches.count
for i in 0...(numberOfRecipiesToDisplay - 1)
{
var time: Int? = ((recipieMatches[i])["totalTimeInSeconds"]) as Int? // THIS LINE
}
Run Code Online (Sandbox Code Playgroud)
我在for循环中的行上得到一个EXC_BAD_ACCESS错误.
我的问题:这怎么可能?我知道recipieMatches[i]是一个值,因为for循环遍历数组的计数.
Apple告诉我,我的应用程序在启动时崩溃了.这是崩溃报告,但我不知道它意味着什么.可能的原因是什么?
CrashReporter Key: 8ebc5eb666109db6d4970a4148cf88160f6805b5
Hardware Model: xxx
Process: Music Player [907]
Path: /private/var/mobile/Containers/Bundle/Application/664B5DFA-4F34-4469-B30D-EC43B25F39E0/Music Player.app/Music Player
Version: 1.0 (1.0)
Code Type: ARM-64 (Native)
Parent Process: launchd [1]
Date/Time: 2015-01-17 10:11:49.478 -0800
Launch Time: 2015-01-17 10:11:28.916 -0800
OS Version: iOS 8.1 (12B410)
Report Version: 105
Exception Type: 00000020
Exception Codes: 0x000000008badf00d
Highlighted Thread: 0
Application Specific Information:
com.ceto.ocakonbes failed to scene-create in time
Elapsed total CPU time (seconds): 0.270 (user 0.270, system 0.000), 8% CPU
Elapsed application CPU time (seconds): 0.007, 0% …Run Code Online (Sandbox Code Playgroud) 我正在尝试完成我的C编程课的作业Xcode。这很简单。它读取一个文本文件,其中包含学生 ID 及其考试成绩的列表。然后它根据这些数据计算总分,并将它们写入另一个文本文件。但是,我不断收到此Bad Access错误消息,内容为:
Thread 1: EXC_BAD_ACCESS(code=1, address=0x7fff00000de4)
Run Code Online (Sandbox Code Playgroud)
我不知道这是什么意思。我该怎么办?
exc-bad-access ×11
ios ×5
iphone ×4
objective-c ×3
cocoa ×2
attributes ×1
c ×1
callstack ×1
crash ×1
macos ×1
nsstring ×1
nstimer ×1
stack-trace ×1
string ×1
super ×1
swift ×1
viewdidload ×1
xcode ×1
xcode4 ×1