我正在尝试创建一个聊天应用程序,当您与另一个人进行对话并从另一个人收到消息时,您会显示本地通知.
到目前为止,我在我看来实现了这个:
else {
// in case the user that sent the message
// is not the same as the one you are currently talking to
var partOfIt = msg.componentsSeparatedByString("\n")[1].componentsSeparatedByString(":")[6] as NSString
var tuple = (partOfIt,fromuser)
println("open up a new view")
let notification: UILocalNotification = UILocalNotification()
notification.timeZone = NSTimeZone.defaultTimeZone()
let dateTime = NSDate(timeIntervalSinceNow: 2)
notification.fireDate = dateTime
notification.alertBody = "Woww it works!!"
notification.alertAction = "Testing notifications on iOS8"
UIApplication.sharedApplication().scheduleLocalNotification(notification)
Run Code Online (Sandbox Code Playgroud)
不幸的是,除了println.我已经允许在使用我的应用时显示通知.
此外,我还想打开一个新视图.当用户点击此通知时,我该怎么做?
这是我做错了吗?
在我的应用程序中,我有一个包含顶栏和桌子的视图.通过从议程中获取联系人的信息来填充桌面视图.
到目前为止一切正常,但我想从表中选择一个单元格并按下顶部栏上的一个按钮转到另一个视图.不幸的是,这部分根本不起作用.
这是我尝试过的:
class myAgendaTableViewController: UITableViewController ,UINavigationControllerDelegate,ABPeoplePickerNavigationControllerDelegate{
@IBOutlet var EditButton: UIBarButtonItem!
@IBOutlet var table: UITableView!
var objects : NSMutableArray! = NSMutableArray()
var addressBookController :ABPeoplePickerNavigationController!
var contactsArray :NSMutableArray! = NSMutableArray()
//...........//
//the method I assigned to the edit button
@IBAction func pressedEdit(sender: UIBarButtonItem) {
self.objects.insertObject(NSDate.date(), atIndex: 0)
var indexPath = NSIndexPath(forRow: 0, inSection: 0)
var array :NSMutableArray = NSMutableArray()
var ContactDetailsView : ContactDetails
ContactDetailsView = self.storyboard.instantiateViewControllerWithIdentifier("Agenda") as ContactDetails
var personDict = self.contactsArray.objectAtIndex(0) as NSDictionary
//println(personDict.objectForKey("firstName") ) //the dictionary exists and all …Run Code Online (Sandbox Code Playgroud) 我不太了解python,所以请耐心等待我:
假设我们有一个具有这种形式的元组:
locations = [('John' , 32 , 21) , ('Michael' , 23 , 12)]
Run Code Online (Sandbox Code Playgroud)
如何将它们连接到一个看起来像的字符串
"约翰32 21
迈克尔23 12"
我试过这样做:
str1 = '\n'.join( ' '.join(elem[0] elem [1] elem[2]) for elem in locations)
Run Code Online (Sandbox Code Playgroud)
但是我在elem [0],[1],[2]中得到一个错误,说无效的语法
关于如何解决这个问题的任何想法?
我在尝试通过telnet连接到邮件服务器时遇到一些问题。我遇到的主要问题是,我需要创建一个脚本来将我登录到目标位置,而我找不到找到回显密码的方法。
我试过的
telnet host -l username ; echo 'password'
Run Code Online (Sandbox Code Playgroud)
仍然会询问我的密码,有什么办法可以解决这个问题,或者我做错了什么?