草庐IT

Binding_New_Objective-C_Types

全部标签

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

ios - Objective-C : Webviewcontroller is reloading after opening photo gallery

我正在开发一个iOS应用程序。在我的应用程序中,我有一个包含UIWebview的viewController。我在那个WebView中加载了一个url。该网页中有一个“上传”按钮。当我们点击那个按钮时,它会打开手机的照片库,用户可以从图库中选择一张照片。我的问题是在从图库中选择任何照片后,ViewController正在重新加载,并且在WebView中再次打开相同的url。所以我无法上传任何文件。请大家帮帮我。请。谢谢,AKS 最佳答案 很可能您正在viewdidAppear的webview中加载url:尝试在viewDidLoad

ios - 一旦 NSTimer 停止在 objective-c 中关闭我的 View Controller

我正在使用NSTimer,timer=[NSTimerscheduledTimerWithTimeInterval:1.0target:selfselector:@selector(updateCountdown)userInfo:nilrepeats:YES];然后是我的60秒倒计时程序-(void)updateCountdown{inthours,minutes,seconds;secondsLeft++;hours=secondsLeft/3600;minutes=(secondsLeft%3600)/60;seconds=(secondsLeft%3600)%60;time.t

objective-c - 在运行时替换包中的图像

我可以在运行时替换bundle中的图像吗?基本上,我的bundle中有一些图像,如果图像有任何变化,我也会从服务器获取它们。我能否在运行时将它们放入包中,这样我就无需更改代码来选择图像? 最佳答案 您不能更改应用程序包的内容。但是可以将图像存储在应用程序的文档文件夹中。然后,您将能够覆盖这些图像,以备不时之需。有两种方法可以实现:启动时,检查文档目录中是否存在图像文件。如果没有,请将bundle图像复制到文档文件夹。每次加载图像时,检查它是否存在于文档目录中。如果是,加载它,否则从包中加载一个。这样可以避免复制数据,从而减少磁盘使用