其他人必须在将iOS项目转换为Swift 3时(或之后)收到此消息,但是当我进行Google搜索时,我得不到相关结果.
无论如何,在转换为Swift 3后,我有大约30个警告说:
表达隐含地从'UIView?'强制执行 去任何
但警告并未指出任何特定的代码行.它们仅引用存在警告的类.
有没有人对这个警告有所了解,或者我如何对它们进行沉默?
有没有办法在实际初始化之前声明这样的变量?
CGFloat components[8] = {
0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.15
};
Run Code Online (Sandbox Code Playgroud)
我想它声明这样的东西(除了这不起作用):
CGFloat components[8];
components[8] = {
0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.15
};
Run Code Online (Sandbox Code Playgroud) 我设置了一个构建并添加了两个内部测试人员.在按下"邀请"按钮后,我立即注意到我的电子邮件地址旁边的复选框是唯一一个仍然检查的复选框.第二个测试人员旁边的复选框未选中.所以我点击了复选框并发送了另一个邀请,但同样的事情发生了.我没有想到它,认为当他实际安装和测试应用程序时它会被检查.但他说他从未收到邀请.有谁知道我做错了什么?

这会导致应用崩溃:
[[UINavigationBar appearance] setTitleColor:[UIColor darkGrayColor] forState:UIControlStateNormal];
Run Code Online (Sandbox Code Playgroud)
有没有办法用外观做到这一点?
在Xcode 6测试版中,当我删除约束时,它不会完全删除它,而是将其灰显.我认为那意味着约束被用在不同的大小类中,但似乎并非如此.另外,你如何永久删除这些约束?
在"可可设计模式"一书中,作者有时会在@interface中声明一个属性为readonly:
// .h
@property (readonly, copy) NSArray *shapesInOrderBackToFront;
Run Code Online (Sandbox Code Playgroud)
然后在实现(.m)文件中添加一个未命名的类别,如下所示:
// .m
@interface MYShapeEditorDocument ()
@property (readwrite, copy) NSArray *shapesInOrderBackToFront;
@end
Run Code Online (Sandbox Code Playgroud)
知道为什么?我不清楚这种方法如何比最初将该属性声明为"readwrite"更好或更必要.
任何人都知道为什么CGContextFillPath不能在下面的代码片段中工作?我正在使用以下代码绘制到UIImageView.它正确地描述了路径,但忽略了CGContextFillPath.
UIGraphicsBeginImageContext(self.frame.size);
[drawingView.image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 5.0);
CGContextSetAllowsAntialiasing(UIGraphicsGetCurrentContext(), YES);
CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 1.0, 0.0, 0.0, 1.0);
CGContextSetRGBFillColor(UIGraphicsGetCurrentContext(), 1.0, 0.0, 0.0, 1.0);
CGContextBeginPath(UIGraphicsGetCurrentContext());
CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), firstMovedTouch.x, firstMovedTouch.y);
CGContextStrokePath(UIGraphicsGetCurrentContext());
CGContextFillPath(UIGraphicsGetCurrentContext());
drawingView.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
Run Code Online (Sandbox Code Playgroud) 给定一个字符串,我需要获得该字符串中出现的每个单词的计数.为此,我通过单词将字符串提取为数组,然后以这种方式进行搜索,但我觉得直接搜索字符串更为理想.下面是我最初编写的用于解决问题的代码.我想提出更好的解决方案的建议.
NSMutableDictionary *sets = [[NSMutableDictionary alloc] init];
NSString *paragraph = [[NSString alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"text" ofType:@"txt"] encoding:NSUTF8StringEncoding error:NULL];
NSMutableArray *words = [[[paragraph lowercaseString] componentsSeparatedByString:@" "] mutableCopy];
while (words.count) {
NSMutableIndexSet *indexSet = [[NSMutableIndexSet alloc] init];
NSString *search = [words objectAtIndex:0];
for (unsigned i = 0; i < words.count; i++) {
if ([[words objectAtIndex:i] isEqualToString:search]) {
[indexSet addIndex:i];
}
}
[sets setObject:[NSNumber numberWithInt:indexSet.count] forKey:search];
[words removeObjectsAtIndexes:indexSet];
}
NSLog(@"%@", sets);
Run Code Online (Sandbox Code Playgroud)
例:
起始字符串:
"这是一个测试.这只是一个测试."
结果:
既然公众知道App Store提交的内容正在使用私有API进行测试,我需要问一个问题......私有API究竟是什么,以便我可以避免使用它们?
我在swift文件中有这个变量:
var adbk: ABAddressBook!
Run Code Online (Sandbox Code Playgroud)
这一直很好,直到Xcode 7.1.现在它抱怨"具有retain或strong属性的属性必须是对象类型." 错误发生在-Swift.h文件中.知道改变了什么会导致这种情况以及如何解决它?
ios ×6
xcode ×4
ios8 ×2
iphone ×2
objective-c ×2
c ×1
categories ×1
cgcontext ×1
nsset ×1
nsstring ×1
properties ×1
quartz-2d ×1
swift ×1
swift3 ×1
testflight ×1
xcode6 ×1
xcode7.1 ×1