我收到一个错误,我不明白如何解决.错误是:
Sending 'CGFloat' (aka 'float') to parameter of incompatible type 'CGFloat *' (aka 'float *');
Run Code Online (Sandbox Code Playgroud)
对于线路:
[xlabel.text drawAtPoint:CGPointMake(labelRect.origin.x, labelRect.origin.y)
forWidth:labelRect.size.width
withFont:myFont
minFontSize:5.0
actualFontSize:myFont.pointSize
lineBreakMode:UILineBreakModeWordWrap
baselineAdjustment:UIBaselineAdjustmentAlignCenters];
Run Code Online (Sandbox Code Playgroud)
错误指向actualFontSize:myFont.pointSize.myFont是一个UIFont.我这样设置:UIFont *myFont = [UIFont systemFontOfSize:17.0];
这个错误意味着什么,以及如何修复它的想法?
异常发生的一般原因是什么?出现异常时,程序是立即终止还是继续运行?
我猜@try是我正在测试的程序消息.是对的吗?
@catch之后要么记录错误信息,要么清理等等,@ final块会做什么?我正在阅读的书中说@finally确定@try中的语句是否会引发异常.但这不是一个不必要的步骤,因为有或没有它,我们可以判断是否存在基于程序突然终止的异常?
什么是投掷指令?这些书说它可以让你抛出自己的异常.但我发现这真的令人困惑.这是否意味着我可以以某种方式创建一个例外并测试它?
如果你能为我回答至少一个问题,我将非常感激.谢谢.
我是个新手,所以慢慢来。
我正在 swift 中制作一个应用程序,并且有一个变量 dateCreated,它是一个日期格式为“yyyy-MM-dd”的字符串。
我正在尝试创建另一个变量 currentDate 即当前日期,并以 Int 形式查找它们之间的天数。
有人可以帮我找出最好的方法吗?我尝试使用在该网站上找到的类似问题中的方法,但似乎没有任何效果。
- (void)buttonSave:(UIButton *)bttnSave
{
UILabel *lbl = (UILabel *)[self.view viewWithTag:kTagLblText];
[dicStore setValue:lbl.textColor forKey:@"Text Color"];
// fltValue is float type
[dicStore setObject:fltValue forKey:@"font"];
[dicStore setValue:strtextView forKey:@"Text Style"];
[arrStoreDic addObject:dicStore];
}
Run Code Online (Sandbox Code Playgroud)
如果我们可以存储这个,那么任何人都可以帮助我做
@IBAction func blueBtnAct(_ sender: AnyObject) {
score++ //error bcause Unary operator '++' cannot be applied to an operand of type '@lvalue Int'
blueLbl.text = "\(score)"
GrenLbl.text = "\(score)"
testScore()
}
@IBAction func GrenBtnAct(_ sender: AnyObject) {
score-- //error bcause Unary operator '--' cannot be applied to an operand of type '@lvalue Int'
blueLbl.text = "\(score)"
GrenLbl.text = "\(score)"
testScore()
}
Run Code Online (Sandbox Code Playgroud) 每次我尝试创建一个新类时,我都会得到一堆错误,甚至没有编写一行代码.
register.h
#import <UIKit/UIKit.h>
@interface register : UIViewController
@end
Run Code Online (Sandbox Code Playgroud)
给出错误:
预期标识符
预期标识符或'('
register.m
#import "register.h"
@interface register ()
@end
@implementation register
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
Run Code Online (Sandbox Code Playgroud)
@implementation注册
预期标识符
预期标识符或'('
- (void)viewDidLoad并- (void)didReceiveMemoryWarning给:
缺少方法声明的上下文
@end 得到:
@end必须出现在objective-c上下文中
每次我创建一个新类而不编写任何代码时都会发生这种情况.