草庐IT

trace_object_allocations

全部标签

objective-c - 影响保留计数的因素

我很难定位内存泄漏。我正在使用cocos2d。这是两个类的数据区域:@interfaceDungeon:CCLayerColor{DungeonLevel*aDungeonLevel;Player*thePlayer;//listofallmonsterfilenamesNSMutableArray*monsterNames;//arrayofhowmanymonstersthereareofeachmonsterlevelNSMutableArray*monsterLevels;MessageView*theMessageView;DungeonDisplay*theDisplay;

objective-c - ^ 符号在 Objective-C 中是什么意思?

这个问题在这里已经有了答案:关闭10年前。PossibleDuplicate:CaretinobjectiveCObjective-C中的^符号是什么意思?代码:GreeRequestServicePopup*requestPopup=[GreeRequestServicePopuppopup];requestPopup.parameters=parameters;requestPopup.willLaunchBlock=^(idaSender){[[NSNotificationCenterdefaultCenter]postNotificationName:@"request_ser

objective-c - IOS重复接口(interface)定义

你好,我的.h文件中有以下代码import@interfaceNSFont:NSObject{}@end@interfaceNSParagraphStyle:NSObject{}@end我得到了那个错误:error:duplicateinterfacedefinitionforclass'NSParagraphStyle'我没有像一些用户指出的那样包含也没有重复main.m导入#import偏好#ifdef__OBJC__#import#import#endif 最佳答案 NSParagraphStyle是在最新(未发布)版本的iO

objective-c - NSUserDefaults 正确存储 NSDate,然后在第二次检索后返回 null

我正在尝试使用NSUserDefaults存储和检索startTime和endTimeNSDate。存储它们似乎不是问题:self.convertedStringToDate=convertDateNSLog(@"Thisshouldread16:00:%@",self.convertedStringToDate);NSUserDefaults*userDefaults=[NSUserDefaultsstandardUserDefaults];[userDefaultssetObject:convertDateforKey:@"startDate"];[userDefaultssync

objective-c - 如何知道在 Objective-C 中哪个方法执行了选择器

我有一个非常简单的示例,但我无法理解如何获取有关在其中调用选择器的方法的信息。例如:-(void)methodOne{[selfperformSelector:@selector(methodTwo:)];}-(void)methodTwo:(id)sender{//Howtoknowwhichmethodperformedselector???}我觉得这个例子很简单,我只需要理解这一点,再一次,问题是,我怎么知道methodTwo:哪个方法执行选择器,所以我从哪个方法调用方法二:.提前致谢! 最佳答案 如果您想知道哪个方法调用了您

objective-c - 如何在 iOS 中将数字显示为持续时间的一小时?

有没有办法将持续时间中的数字显示为小时?例如,我有一个包含127的NSTimeInterval值,我想显示02:07。这样做的更好方法是什么?谢谢。 最佳答案 尽情享受吧!:)NSTimeInterval_timeInterval=127.f;NSInteger_hours=_timeInterval/60;NSInteger_minutes=(NSInteger)_timeInterval%60;NSLog(@"%02d:%02d",_hours,_minutes); 关于object

iphone - 如何判断收到了哪个本地通知? Objective-C

我有这段代码根据收到的本地通知调用不同的NSLog语句:-(void)application:(UIApplication*)applicationdidReceiveLocalNotification:(UILocalNotification*)notification{if(notification==automaticBackupNotification){NSLog(@"Backupnotificationreceived.");}else{NSLog(@"Didreceivenotification:%@,setfordate:%@.",notification.alertB

objective-c - NSmanagedObject copyWithZone 问题

我有一个自定义类Thing:NSManagedObject,其属性为adminName。我试图在这个Thing类中创建一个copyWithZone函数,但是当我运行该应用程序时,它说setAdminName不存在。在我使用的实现文件中@dynamicadminName;-(id)copyWithZone:(NSZone*)zone{Thing*regCopy=[[ThingallocWithZone:zone]init];regCopy.attendeeNum=[selfadminName];returnregCopy;}我不相信我可以将@dynamic更改为@synthesize,因

objective-c - 为什么 addSubview 不显示?

我想以编程方式将myView添加到父View。但它没有出现在屏幕上。代码有什么问题?@interfaceViewController()@property(nonatomic,weak)UIView*myView;@end@implementationViewController@synthesizemyView=_myView;-(void)viewDidLoad{[superviewDidLoad];CGRectviewRect=CGRectMake(10,10,100,100);self.myView=[[UIViewalloc]initWithFrame:viewRect];s

ios - 委托(delegate)方法未被称为 Objective-C

我正在尝试将secondViewController中的两个文本字段的数据传递给ViewController并在ViewController中设置标签文本。但是没有调用传递数据的委托(delegate)方法。我已经通过放置断点来检查它。因此标签文本没有改变。SecondViewController.h#import@classSecondViewController;@protocolSecondViewDelegate-(void)getText1:(NSString*)str1andText2:(NSString*)str2;@end@interfaceSecondViewCont