我正在尝试将我的项目转换为Swift 3.0但是在使用NSNumber和时我有两个错误消息Integers.
无法将类型int指定为类型NSNumber
对于
//item is a NSManaged object with a property called index of type NSNumber
var currentIndex = 0
for item in self.selectedObject.arrayOfItems {
item.index = currentIndex
currentIndex += 1
}
Run Code Online (Sandbox Code Playgroud)
甚至当我改变currentIndex一个类型NSNumber然后我得到错误
二进制运算符'+ ='不能应用于'NSNumber'和'Int'类型
所以然后我创建一个名为onetype 的属性NSNumber来添加,currentIndex但后来得到以下错误;
二进制运算符'+ ='不能应用于两个NSNumber操作数
&&我得到的第二个错误是
没有'+'候选者产生预期的上下文结果类型NSNumber
let num: Int = 210
let num2: Int = item.points.intValue
item.points = num + num2
Run Code Online (Sandbox Code Playgroud)
在这里我只想尝试将210添加到points属性值,item是一个NSManagedObject.
所以基本上我遇到了一些问题,我想把数字添加到类型属性中NSNumber.我正在工作,NSNumber …
我试图在访问www.example.com/success时将用户重定向到已安装的应用程序,并在访问主页www.example.com时显示横幅。
\n在我当前的植入中,网址不会重定向并打开应用程序,网站也不会显示横幅。
\n我正在关注此处找到的文档https://developer.apple.com/documentation/safariservices/supporting_linked_domains
\n我的网站很简单create-react-app,主页由 Firebase 托管。
我做了以下事情:
\napple-app-site-association将文件添加到/public/我用什么来验证:
\nhttps://branch.io/resources/aasa-validator/
\nhttps://search.developer.apple.com/appsearch-validation-tool
\n通过将www.example.com/success链接添加到注释并打开进行测试,它总是在 safari 中打开。我还尝试过重新安装应用程序并重新启动手机。
\n苹果API验证
\n我已将带有关联域的新应用程序版本上传到商店
\n\nBranch.io
\n{\n "applinks": {\n "apps": [],\n "details": []\n }\n}\nRun Code Online (Sandbox Code Playgroud)\n访问www.example.com/apple-app-site-association时
\n\n{ "activitycontinuation": { "apps": [ "team.com.example.com" ] },\n"applinks": { "apps": [], "details": [ { …
我试图修改我的压轴错误,同时尝试转换为Swift 3,但我不确定为什么我得到错误
无法将类型'() - > Void'的值转换为预期的参数类型'(( - - > Void)?'
对于
CATransaction.setCompletionBlock(completion)
Run Code Online (Sandbox Code Playgroud)
完整功能
fileprivate func deleteRowsAtIndexPaths(_ indexPaths: [IndexPath], withRowAnimation animation: UITableViewRowAnimation, duration: TimeInterval, completion:() -> Void) {
CATransaction.begin()
CATransaction.setCompletionBlock(completion) //Error
UIView.animate(withDuration: duration) { () -> Void in
self.deleteRows(at: indexPaths, with: animation)
}
CATransaction.commit()
}
Run Code Online (Sandbox Code Playgroud)
有谁知道为什么我得到这个以及如何解决错误?
所以我添加了UISplitViewController一个嵌入了一个项目的项目UITabBarController.
该UISplitViewController有一个UINavigationController与他们自己的根控制器主控和细节的关系.
大师UINavigationController rootController有一个详细信息细节UINavigationController.
看这里:
一切都很简单吧?现在在TableViewController中我做了以下几点;
class TableViewController: TableViewController, UISplitViewControllerDelegate {
var collapseDetailViewController: Bool = false
override func viewDidLoad() {
super.viewDidLoad()
splitViewController?.delegate = self
}
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
collapseDetailViewController = false
}
// MARK: - UISplitViewControllerDelegate
func splitViewController(splitViewController: UISplitViewController, collapseSecondaryViewController secondaryViewController: UIViewController, ontoPrimaryViewController primaryViewController: UIViewController) -> Bool {
return false
}
Run Code Online (Sandbox Code Playgroud)
我也有一个UISplitViewController扩展并执行以下操作;
extension UISplitViewController: UISplitViewControllerDelegate {
public override func viewDidLoad() {
self.extendedLayoutIncludesOpaqueBars = …Run Code Online (Sandbox Code Playgroud) 所以我可以安排这样的通知;
//iOS 10 Notification
if #available(iOS 10.0, *) {
var displayDate: String {
let dateFormatter = DateFormatter()
dateFormatter.dateStyle = DateFormatter.Style.full
return dateFormatter.string(from: datePicker.date as Date)
}
let notif = UNMutableNotificationContent()
notif.title = "I am a Reminder"
notif.subtitle = "\(displayDate)"
notif.body = "Here's the body of the notification"
notif.sound = UNNotificationSound.default()
notif.categoryIdentifier = "reminderNotification"
let today = NSDate()
let interval = datePicker.date.timeIntervalSince(today as Date)
let notifTrigger = UNTimeIntervalNotificationTrigger(timeInterval: interval, repeats: false)
let request = UNNotificationRequest(identifier: "reminderNotif", content: notif, trigger: notifTrigger)
UNUserNotificationCenter.current().add(request, …Run Code Online (Sandbox Code Playgroud) 添加一个名为Unique Identifiermy Enitiy/ NSManagedObjectcalled 的字符串属性后,我收到以下错误Labels.然而,并不是Unique Identifier编制者不满意的.
2016-08-20 02:20:08.394 AN [22499:8730414] - [AN.Labels文件夹]:无法识别的选择器发送到实例0x7ffe907e1a80 2016-08-20 02:20:08.405 AN [22499:8730414]***终止应用程序由于未捕获的异常'NSInvalidArgumentException',原因:' - [AN.Labels文件夹]:无法识别的选择器发送到实例0x7ffe907e1a80'
这是我的NSManagedObject类
class Labels: NSManagedObject {
@NSManaged var title: String?
@NSManaged var details: String
@NSManaged var date: NSDate?
@NSManaged var uniqueIdentifier: NSString?
@NSManaged var arrayOfFolders: [Folders]
@NSManaged var folder: Folders?
@NSManaged var folders: NSSet
override func awakeFromFetch() {
super.awakeFromFetch()
self.regenerateFolders()
}
func regenerateFolders() {
let date = NSSortDescriptor(key: "date", ascending: false)
if let array = …Run Code Online (Sandbox Code Playgroud) 所以我犯了一个巨大的男生错误,我没有将Xcode项目备份到外部驱动器.
该Xcode项目工作时间为6-9个月,预计将在几周后发布.
我从未使用过Git/Github并正在经历树屋课程,所以我可以为项目设置工作流程.(是的,我new to development).
所以我到了创建回购的地步,Github但没有把项目交给回购.我去了本地提交但是出了错误,我不小心点击了丢弃所有更改.我已经丢失了我的应用程序和所有文件.
我去了垃圾桶,看到了一个似乎有所有文件的文件夹,但是我将文件夹拖到桌面并打开了项目,项目为空.
任何人都可以帮助我如何恢复我的项目?
PS:我有一个想法是恢复我上次备份的时间机器,并将我上次备份中的项目替换为从垃圾箱中恢复的项目.但我不知道这是否有效.最后一次备份是在一个月前,是的,我做了很多改动.
我正在使用Ensembles框架与iCloud同步数据.一切正常,直到我迁移到Swift 3.
该框架在Objective-C中,我的appDelegate功能已迁移到Swift 3; 从那以后我就遇到了问题.appDelegate.syncWithCompletion保存更改时,我会调用整个应用程序NSManagedObjects.
这是appDelegate功能
// MARK: Ensembles
var cloudFileSystem: CDECloudFileSystem!
var ensemble: CDEPersistentStoreEnsemble!
func syncWithCompletion(completion:@escaping (_ completed:Bool) -> Void) {
if !ensemble.isLeeched {
ensemble.leechPersistentStore { error in
if error != nil {
print("cannot leech \(error!.localizedDescription)")
completion(false)
}
else {
print("leached!!")
completion(true)
}
}
}
else {
ensemble.merge{ error in
if error != nil {
print("cannot merge \(error!.localizedDescription)")
completion(false)
}
else {
print("merged!!")
completion(true)
//NSNotificationCenter.defaultCenter().postNotificationName("Updated-DB", object: nil)
}
}
}
} …Run Code Online (Sandbox Code Playgroud) 这是我在此处发现的上一个问题的后续跟进
我正在使用MarkdownTextView向a添加基本降价UITextView.它TextView是的子类MarkdownTextView.
在我使用复制和粘贴时的上一个问题中,我收到以下错误
致命错误:对MarkdownTextStorage类使用未实现的初始化程序'init()'
直到我将以下初始化程序添加到MarkdownTextStorage类中
public override convenience init() {
self.init(attributes: MarkdownAttributes())
}
public init(attributes: MarkdownAttributes = MarkdownAttributes()) {
self.attributes = attributes
super.init()
commonInit()
if let headerAttributes = attributes.headerAttributes {
addHighlighter(MarkdownHeaderHighlighter(attributes: headerAttributes))
}
addHighlighter(MarkdownLinkHighlighter())
addHighlighter(MarkdownListHighlighter(markerPattern: "[*+-]", attributes: attributes.unorderedListAttributes, itemAttributes: attributes.unorderedListItemAttributes))
addHighlighter(MarkdownListHighlighter(markerPattern: "\\d+[.]", attributes: attributes.orderedListAttributes, itemAttributes: attributes.orderedListItemAttributes))
// From markdown.pl v1.0.1 <http://daringfireball.net/projects/markdown/>
// Code blocks
addPattern("(?:\n\n|\\A)((?:(?:[ ]{4}|\t).*\n+)+)((?=^[ ]{0,4}\\S)|\\Z)", attributes.codeBlockAttributes)
// Block quotes
addPattern("(?:^[ \t]*>[ \t]?.+\n(.+\n)*\n*)+", attributes.blockQuoteAttributes)
// Se-text style …Run Code Online (Sandbox Code Playgroud) 我知道这是一个非常基本的问题,我知道我可能找不到答案,因为我没有问正确的问题但是我怎样才能更改NSDate值?
例如,我有一个date属性设置为a的日期,datePicker我想创建一个新属性,它是属性的前一天date,另一个属性是一小时前.