小编JUS*_*DEV的帖子

"留言回复花了太长时间." - 观察Watch OS 3的连接问题

在我的项目中,我Watch Connectivity用来向Watch和iPhone发送消息.我可以向手机发送消息并在启动应用程序时收到一串字符串,但是在使用操作时,我收到以下错误;

错误域= WCErrorDomain代码= 7012"消息回复花了太长时间."

这是事情的建立方式;

首先,手表向手机发送消息,然后手机发送一串字符串以显示在手机中WKInterfaceTable.这有时适用于加载应用程序.(我获取所有调用的NSManagedObjects Items并使用它们的title字符串属性存储在被array调用的中watchItems.

但是,我在手表上有一个操作,删除数组中的所有项目并使用新数据刷新表格.

手表上的操作使用一个sendMessage功能发送item到手机以从阵列中删除,然后手机将新更新的阵列发送到手表,手表更新表.但是,我要么返回相同的数组,要么出错.

非常简单,所以在Swift 3和Watch OS3/iOS 10之前一切正常工作; 整个应用程序曾经工作过.

这是我如何设置一切;

电话应用代表

import WatchConnectivity

class AppDelegate: UIResponder, UIApplicationDelegate, WCSessionDelegate {

var session : WCSession!

var items = [Items]()

func loadData() {
    let moc = (UIApplication.shared.delegate as! AppDelegate).managedObjectContext
    let request = NSFetchRequest<Items>(entityName: "Items")

    request.sortDescriptors = [NSSortDescriptor(key: "date", ascending: true)]
    request.predicate = NSPredicate(format: "remove == 0", "remove")

    do {
        try
            self.items = …
Run Code Online (Sandbox Code Playgroud)

ios swift watchconnectivity watchos-3

38
推荐指数
1
解决办法
1284
查看次数

使用swift在设定的时间每天重复本地通知

我是iOS开发的新手,但已经创建了应用程序,我正在尝试创建一段时间的每日通知.目前,通知对于给定的日期/时间执行一次.我不确定如何使用repeatInterval方法每天安排它.每天重复通知的最佳方法是什么?任何帮助将不胜感激(Y).

    var dateComp:NSDateComponents = NSDateComponents()
    dateComp.year = 2015;
    dateComp.month = 06;
    dateComp.day = 03;
    dateComp.hour = 12;
    dateComp.minute = 55;
    dateComp.timeZone = NSTimeZone.systemTimeZone()

    var calender:NSCalendar = NSCalendar(calendarIdentifier: NSCalendarIdentifierGregorian)!
    var date:NSDate = calender.dateFromComponents(dateComp)!

    var notification:UILocalNotification = UILocalNotification()
    notification.category = "Daily Quote"
    notification.alertBody = quoteBook.randomQuote()
    notification.fireDate = date
    notification.repeatInterval = 

    UIApplication.sharedApplication().scheduleLocalNotification(notification)
Run Code Online (Sandbox Code Playgroud)

cocoa-touch ios uilocalnotification swift

14
推荐指数
2
解决办法
2万
查看次数

使用S3/EC2时删除".php"文件扩展名

我已经设置了一个应用程序并使用弹性beanstalk上传了这些文件.这些文件保存在运行EC2实例的S3存储桶中.

问题是我只能在手动添加扩展名".php"时访问站点文件.

我使用.htaccess文件构建应用程序以删除文件扩展名然后我的重定向和函数将使用没有结尾的文件,例如"/ index"而不是"/index.php".

因为.htaccess不是使用S3存储桶的选项,是否有一种删除文件扩展名的简单替代方法?(所以"/index.php"文件读作"/ index",然后所有函数/重定向工作正常).

apache .htaccess amazon-s3 amazon-ec2 amazon-web-services

6
推荐指数
1
解决办法
657
查看次数

如何在消息扩展中发送MSMessage?

我想实现一个imessage应用程序,但是对于消息框架是新手,而iMessage应用程序是一个新东西,没有太多资源.所以我正在关注WWDC视频并使用Apples为指南提供示例应用程序.

我有三个视图,MessageViewController它们处理几乎所有的功能,然后是a CreateViewController和a DetailsViewController.

我只是想创建一个MSMessageCreateViewController并显示在DetailsViewController..然后添加到数据.

但是,在尝试创建数据时,我遇到了崩溃.

@IBAction func createAction(_ sender: AnyObject) {
    //present full screen for create list
    self.delegate?.createViewControllerDidSelectAdd(self as! CreateViewControllerDelegate)        
}
Run Code Online (Sandbox Code Playgroud)

我试图传递的数据类型是结构中的字典:

struct data {
var title: String!
var date: Date!

var dictionary = ["title" : String(), "Array1" : [String](), "Array2" : [String]() ] as [String : Any]

}
Run Code Online (Sandbox Code Playgroud)

所以这里是如何建立的;

MessagesViewController

class MessagesViewController: MSMessagesAppViewController, {

// MARK: Responsible for create list button

func composeMessage(for data: …
Run Code Online (Sandbox Code Playgroud)

ios swift swift3 ios10 msmessage

5
推荐指数
1
解决办法
918
查看次数

如何在Swift中使用Dictionary构建URL

所以我正在搞乱iMessages框架,为了将数据发送给另一个用户,数据必须作为一个发送URLComponents URL.但是我无法弄清楚如何发送字典作为messages.url值.

func createMessage(data: dictionary) {

    /*

     The Dictionary has 3 values, 1 string and two arrays. 

    let dictionary = ["title" : "Title Of Dictionary", "Array1" : [String](), "Array2" : [String]() ] as [String : Any]

    */ 


    let components = URLComponents()

    let layout = MSMessageTemplateLayout()
    layout.image = UIImage(named: "messages-layout.png")!
    layout.imageTitle = "\(dictionary["title"])"

    let message = MSMessage()
    message.url = components.url!
    message.layout = layout

    self.activeConversation?.insert(message, completionHandler: { (error: Error?) in
        print("Insert Message")
    })
}
Run Code Online (Sandbox Code Playgroud)

有谁知道我可以送字典值URLQueryItems …

ios imessage swift swift3 ios10

4
推荐指数
1
解决办法
1986
查看次数