我有一个UITextField,我将其添加到a UITableViewCell用作一长串帐户的搜索字段.我添加如下:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
}
if ((indexPath.section < accountsection) && (hasSearch) && (indexPath.row == 0))
{
// Search
if (!searchField)
{
searchField = [[UITextField alloc] initWithFrame:CGRectMake(20, 10, cell.frame.size.width - 40, 25)];
[searchField setEnabled:YES];
searchField.placeholder = NSLocalizedString(@"Search", @"search");
searchField.keyboardType = UIKeyboardTypeDefault;
searchField.returnKeyType = UIReturnKeySearch;
searchField.autocorrectionType = UITextAutocorrectionTypeNo;
searchField.clearButtonMode = UITextFieldViewModeAlways;
searchField.delegate = self; …Run Code Online (Sandbox Code Playgroud) 我(我认为)在我的代码中遇到了一个非常棘手的问题.它在代码中的不同位置随机崩溃.该项目是一个ARC项目.
所以我的程序偶尔崩溃了这条消息:
malloc: *** error for object 0xd2dd8b0: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug
Run Code Online (Sandbox Code Playgroud)
我已经设置了一个断点,malloc_error_break但我没有得到任何信息.当代码崩溃时,XCode会向我显示代码所在的位置.但正如我已经说过的那样,崩溃是随机的,不会一直发生.但似乎崩溃集中在代码中的特定行.
现在,我想使用xcode附带的仪器进行调试.经过一段谷歌搜索后,我在stackoverflow上发现了以下内容:如何在Xcode 4中设置NSZombieEnabled?和Xcode malloc错误.
因此,第一个链接描述了如何通过单击xcode中的运行按钮从xcode本身开始进行僵尸检测并选择"Profile".我遇到的问题是,在我的xcode版本(4.2)中选择跟踪文档的模板时,我找不到"Zombies".但是如果我在xcode之外启动Instruments(例如来自finder),我可以选择僵尸.
好的,这就是我做的:
1)从finder启动Instruments并选择Profile"Zombies".
2)在iphone模拟器中从xcode启动iphone应用程序(正常运行(不是配置文件或调试)).
3)在仪器"选择目标" - >"附加到过程" - >"iPhone模拟器(57529)".
4)乐器开始重新录制(我无法弄清楚它的作用).
5)开始玩应用程序直到它崩溃.
最终应用程序崩溃,这是崩溃应用程序后的仪器截图:

我的问题:
1)僵尸是否足以解决我的问题,还是应该使用其他分析工具?
2)什么告诉我撞击后输出的乐器?
跳过所有这些信息并跳到底部的更新...
我之前已经处理过无法识别的选择器,但我无法弄清楚这次发生了什么.调用堆栈是不透明的,我无法找出问题的起源.我尝试过使用符号和异常断点.这段代码之前工作得很完美.我再回来研究这个程序了,现在我正在尝试这个
[UITableViewSectionElement numberOfSections]: unrecognized selector sent to instance 0xa285d50
Run Code Online (Sandbox Code Playgroud)
我UITableViews在这个视图控制器中有两个.其中一个被连接起来IB(datasource and delegate).第二个在代码中实例化,其数据源/委托也指向视图控制器.我在第二个tableview上放了一个2的标记,以区分它们.UITableViewTwo添加到a UIView,如果我有要显示的有效数据,它将作为第一个tableview的页脚返回.再一次,这段代码完美地工作,一段时间没有任何崩溃,我似乎无法弄清楚为什么它现在崩溃.我正在使用ARC.
这是一些代码:
当我检查发送选择器的对象的地址是什么时:它确实是一个UITableViewSectionElement.为什么H接收到呼叫号码部分?不应该是numberOfSectionsInTableView吗?
UITableView Delegate/DataSource methods
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (tableView.tag == 0) {
if (indexPath.row == 0) {
PCFCustomNumberReviewsCell *cell = [self.tableViewOne dequeueReusableCellWithIdentifier:@"PCFNumberOfRatings"];
[cell.numberOfReviews setText:[NSString stringWithFormat:@"%d", numReviews.integerValue]];
[cell.numberOfReviews setFont:[PCFFontFactory droidSansFontWithSize:17]];
[cell.numberOfReviews setTextColor:[UIColor lightGrayColor]];
UIImageView *imgView = [[UIImageView alloc] initWithFrame:cell.frame];
[imgView setImage:[UIImage imageNamed:@"1slot2.png"]];
[cell setBackgroundView:imgView];
return cell;
}else if(indexPath.row == 1) {
PCFCustomReviewCell …Run Code Online (Sandbox Code Playgroud) 只是花了一些时间......在崩溃时,没有理解它.那是经典之作:
Exception Type: EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x00000010
Run Code Online (Sandbox Code Playgroud)
这导致了一个内存问题,解决了无效的地址 0x10
困扰我的是我有崩溃报告和堆栈跟踪,它们有所不同:
崩溃报告,由用户发送(符号化成功,发生):
Thread 0 Crashed:
0 libobjc.A.dylib 0x000027d8 objc_msgSend + 16
1 UIKit 0x0005e9d2 -[UIViewAnimationState animationDidStop:finished:] + 54
2 QuartzCore 0x0002d8c2 run_animation_callbacks(double, void*) + 286
3 QuartzCore 0x0002d764 CA::timer_callback(__CFRunLoopTimer*, void*) + 116
4 CoreFoundation 0x000567f4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 8
5 CoreFoundation 0x000562a6 __CFRunLoopDoTimer + 854
6 CoreFoundation 0x0002779e __CFRunLoopRun + 1082
7 CoreFoundation 0x00027270 CFRunLoopRunSpecific + 224
8 CoreFoundation 0x00027178 CFRunLoopRunInMode + 52
9 GraphicsServices 0x000045ec GSEventRunModal + 108 …Run Code Online (Sandbox Code Playgroud) 我正在按照惯例制作一个不错的应用程序,然后就会发生这种情况!你在我的应用程序中旋转命运之轮,当旋转动画完成时,应用程序应该随机化一个数字,并显示匹配为数字索引的卡.
这些卡存储在NSMutableArray中,在第一次调用时工作正常.例如.当应用程序随机化数字"1"卡号1被调用并显示没有问题!但是一旦随机发生器再次点击"1",应用程序就会在下面指定的行上崩溃.
这是代码,请帮帮我:)
NSNumber *cardNumber;
cardNumber = [NSNumber numberWithUnsignedInt:arc4random()%[appDelegate.cardArray count]];
NSLog(@"%@", cardNumber);
SpinCard *selectedCard = [appDelegate.cardArray objectAtIndex:[cardNumber doubleValue]];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
[snurrKnapp setAlpha:100];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:cardView cache:YES];
[UIView commitAnimations];
[snurrKnapp setEnabled:YES];
if(![cardTitle.text isEqualToString:selectedCard.cardTitle]) { //Crashes here
[cardTitle setText:selectedCard.cardTitle]; //If I remove the if-case it crashes here
[cardContent setText:selectedCard.cardContent];
}
[selectedCard release];
Run Code Online (Sandbox Code Playgroud)
这是我得到的错误:
2011-04-21 23:10:54.296 Snurra Flaskan[947:707] 0
2011-04-21 23:10:58.794 Snurra Flaskan[947:707] 2
2011-04-21 23:11:02.691 Snurra Flaskan[947:707] 1
2011-04-21 23:11:08.977 Snurra Flaskan[947:707] 2
warning: Unable to read symbols for …Run Code Online (Sandbox Code Playgroud) 我UITableViewController didSelectRowAtIndexPath通过以下方式覆盖了我的方法:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
PhotoListViewController *photosViewController = [[PhotoListViewController alloc] initWithStyle:UITableViewStylePlain];
NSLog(@"Let's see what we got %d", [[fetchedResultsController fetchedObjects] count]);
Person *person = [fetchedResultsController objectAtIndexPath:indexPath];
photosViewController.person = person;
photosViewController.title = [person.name stringByAppendingString:@"'s Photos"];
[self.navigationController pushViewController:photosViewController animated:YES];
[photosViewController release];
}
Run Code Online (Sandbox Code Playgroud)
每当我试图访问fetchedResultsController我得到崩溃时,我在这里设置它:
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"person = %@", person];
fetchedResultsController = [[FlickrFetcher sharedInstance] fetchedResultsControllerForEntity:@"Photo" withPredicate:predicate];
}
return self;
}
Run Code Online (Sandbox Code Playgroud)
我只用我的dealloc方法发布它
exc-bad-access objective-c uitableview didselectrowatindexpath ios
我对Xcode4比较陌生,我想知道如何用它来识别双版本.
在调试器中,我看到一行*** -[NSConcreteMutableData release]: message sent to deallocated instance 0x60b63fe0.
问题是知道地址对识别对象没有多大帮助,而且对象类型也没有太多帮助识别它.
我阅读http://www.friday.com/bbum/2010/01/10/using-malloc-to-debug-memory-misuse-in-cocoa/但我没有发现这太成功了.
objective-c ×4
ios ×3
iphone ×3
uitableview ×2
xcode ×2
crash ×1
instruments ×1
nsnumber ×1
nsstring ×1
nszombie ×1
random ×1
report ×1
stack-trace ×1
uitextfield ×1
xcode4 ×1