我很困惑为什么会出现这个警告。我在其他完美运行的控制器上使用相同的程序。
ConditionTableViewController.m:57:警告:传递'initWithCondition:'的参数1从指针中生成整数而没有强制转换
使用以下代码
- (void)managedObjectSelected:(NSManagedObject *)managedObject
{
// Load View
Condition *con = (Condition *)managedObject;
ConditionDetailViewController *detail = [[ConditionDetailViewController alloc] initWithCondition:con];
detail.title = [[managedObject valueForKey:@"cave"] valueForKey:@"title"];
self.navigationItem.backBarButtonItem =
[[[UIBarButtonItem alloc] initWithTitle:@"Back"
style: UIBarButtonItemStyleBordered
target:nil
action:nil] autorelease];
[self.navigationController pushViewController:detail animated:YES];
[detail release];
}
在ConditionDetailViewController.h中
- (id)initWithCondition:(Condition *)aCondition;
这里控制台输出“con”
2011-07-26 11:03:08.485 CaveConditions[10631:f203] <NSManagedObject: 0xe6628e0> (entity: Condition; id: 0xe6608b0 <x-coredata://368AFBD3-2C66-4ED7-977D-AB8EED8BB577/Condition/p149> ; data: {
cave = "0x67486e0 <x-coredata://368AFBD3-2C66-4ED7-977D-AB8EED8BB577/Cave/p7>";
ccId = 678;
comment = "";
diveDate = 1286830059;
flow = "0xe668270 <x-coredata://368AFBD3-2C66-4ED7-977D-AB8EED8BB577/Flow/p1>";
imageURL = "orbe_doof.jpg";
insertDate = nil;
ip = "xxx.xxx.xxx.xxx";
line = "0xe668280 <x-coredata://368AFBD3-2C66-4ED7-977D-AB8EED8BB577/Line/p1>";
percolation = "0xe668290 <x-coredata://368AFBD3-2C66-4ED7-977D-AB8EED8BB577/Percolation/p5>";
sediment = "0xe6682a0 <x-coredata://368AFBD3-2C66-4ED7-977D-AB8EED8BB577/Sediment/p2>";
temperature = 13;
userMail = "xxx@xxx.ch";
username = "Hans K...";
visibility = "0xe6682b0 <x-coredata://368AFBD3-2C66-4ED7-977D-AB8EED8BB577/Visibility/p7>";
})
按要求包含
ConditionTableViewController.h
#import "CellTableViewController.h"
#import "Cave.h"
ConditionTableViewController.m(调用managedObjectSelected方法的地方)
#import "ConditionTableViewController.h"
#import "ConditionDetailViewController.h"
ConditionDetailViewController.h
#import <UIKit/UIKit.h>
#import "Condition.h"
#import <QuartzCore/QuartzCore.h>
ConditionDetailViewController.m
#import "ConditionDetailViewController.h"
#import "DataProcessor.h"
#import "PhotoViewController.h"
答案 0 :(得分:0)
initWithCondition:
是Foundation框架中采用整数的NSConditionLock
类的方法。我认为Xcode在某种程度上混淆了两个类中的符号名initWithCondition:
,并使用了错误的版本。如果您的代码是正确的,包括在每个文件中导入正确的标头,那么它可能是错误的索引或预编译的标头。尝试从“管理器”窗口的“项目”部分删除项目的派生数据,然后重建项目。