小编Che*_*rif的帖子

如何使用SwiftyJSON循环JSON?

我有一个可以用SwiftyJSON解析的json:

if let title = json["items"][2]["title"].string {
     println("title : \(title)")
}
Run Code Online (Sandbox Code Playgroud)

完美的工作.

但我无法绕过它.我试过两种方法,第一种是

// TUTO :
//If json is .Dictionary
for (key: String, subJson: JSON) in json {
    ...
}
// WHAT I DID :
for (key: "title", subJson: json["items"]) in json {
    ...
}
Run Code Online (Sandbox Code Playgroud)

XCode不接受for循环声明.

第二种方法:

// TUTO :
if let appArray = json["feed"]["entry"].arrayValue {
     ...
}
// WHAT I DID :
if let tab = json["items"].arrayValue {
     ...
}
Run Code Online (Sandbox Code Playgroud)

XCode不接受if语句.

我究竟做错了什么 ?

json ios swift swifty-json

34
推荐指数
3
解决办法
3万
查看次数

如何使用swift将对象数组保存到NSUserDefault?

这是Place我定义的一个类:

class Place: NSObject {

    var latitude: Double
    var longitude: Double

    init(lat: Double, lng: Double, name: String){
        self.latitude = lat
        self.longitude = lng
    }

    required init(coder aDecoder: NSCoder) {
        self.latitude = aDecoder.decodeDoubleForKey("latitude")
        self.longitude = aDecoder.decodeDoubleForKey("longitude")
    }

    func encodeWithCoder(aCoder: NSCoder!) {
        aCoder.encodeObject(latitude, forKey: "latitude")
        aCoder.encodeObject(longitude, forKey: "longitude")
    }

}
Run Code Online (Sandbox Code Playgroud)

这就是我试图保存Places 数组的方法:

var placesArray = [Place]

//...

func savePlaces() {
    NSUserDefaults.standardUserDefaults().setObject(placesArray, forKey: "places")
    println("place saved")
}
Run Code Online (Sandbox Code Playgroud)

它不起作用,这是我在控制台上得到的:

Property list invalid for format: 200 (property lists cannot contain objects …
Run Code Online (Sandbox Code Playgroud)

nsuserdefaults ios swift

28
推荐指数
7
解决办法
3万
查看次数

如何在Swift字符串中包含表情符号?

是一篇非常好的文章,它引用了iOS表情符号及其代码.例如\ue008对于小型相机.

我在我的代码中试过这个:

var myText: String = "\ue008"
Run Code Online (Sandbox Code Playgroud)

xCode不接受此操作.如何包含它?

string nsstring swift

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

我本地化Info.plist后生成错误

我本地化了Info.plist:

在此输入图像描述

我得到了这个构建错误:

error: could not read data from '/Users/cherif/Apps/Wesh/Info.plist': 
The file “Info.plist” couldn’t be opened because there is no such file.
Run Code Online (Sandbox Code Playgroud)

实际上现在有两个Info.plist文件:

fr.lproj/Info.plist
Base.lproj/Info.plist
Run Code Online (Sandbox Code Playgroud)

如何本地化Info.plist路径?

xcode localization objective-c ios swift

16
推荐指数
2
解决办法
6953
查看次数

使用带有NodeJs HTTPS的certificates.cer

我为IOS推送通知生成了一个.cer文件,我希望将它与NodeJS HTTPS模块一起使用.

我发现HTTPS模块的唯一例子是使用.pem和.sfx文件,而不是.cer:

var options = {
  key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'),
  cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem')
};

or 

var options = {
  pfx: fs.readFileSync('server.pfx')
}

https.createServer(options, function (req, res) {
  res.writeHead(200);
  res.end("hello world\n");
}).listen(8000);
Run Code Online (Sandbox Code Playgroud)

有解决方案吗

https ssl-certificate apple-push-notifications node.js ios

8
推荐指数
2
解决办法
4115
查看次数

Cordova Facebook插件:缺少变量APP_ID,APP_NAME

当我做 :

cordova plugin add https://github.com/phonegap/phonegap-facebook-plugin.git
Run Code Online (Sandbox Code Playgroud)

我收到错误:

Error: Variable(s) missing: APP_ID, APP_NAME
Run Code Online (Sandbox Code Playgroud)

我在哪里配置这些变量?

phonegap-plugins cordova cordova-3 cordova-plugins

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

如何使用HTML-CSS表获取垂直文本省略号?

我想在一个只有两行可以容纳的小空间中显示文本.当文本太长时,我正在寻找一种在第二行末尾获得省略号的方法.

在此输入图像描述

我用了一张桌子,但它不起作用,我无法限制细胞高度.

<td style="overflow-x: hidden;overflow-y:hidden;text-overflow: ellipsis;max-height:50px">text</td>
Run Code Online (Sandbox Code Playgroud)

html css html5 html-table ellipsis

7
推荐指数
1
解决办法
5600
查看次数

使用iOS 8调用Parse.com云功能时出现SSL错误

在调用CloudCode函数时,我有时会在iOS 8上遇到错误.它有时只会发生,我不明白为什么:

Error: Error Domain=Parse Code=100 "The operation couldn’t be completed. (Parse error 100.)" UserInfo=0x17ed2150 

{   Code=100, 
    error=Error Domain=NSURLErrorDomain Code=-1200 "An SSL error has occurred and a secure connection to the server cannot be made."
    UserInfo=0x19d0c750 {
        NSLocalizedDescription=An SSL error has occurred and a secure connection to the server cannot be made.,
        NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?, 
        _kCFStreamErrorCodeKey=-9824, 
        NSErrorFailingURLStringKey=https://api.parse.com/1/functions/weshread,
        _kCFStreamErrorDomainKey=3, 
        NSUnderlyingError=0x19de4f40 "An SSL error has occurred and a secure connection to the server cannot be made.", …
Run Code Online (Sandbox Code Playgroud)

ssl ios parse-platform

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

MomentJS:减去分钟的问题

这是我在Parse.com CloudCode上部署的代码:

var now = new Date()
var then = moment(now).subtract(20, "minutes").toDate()

console.log(now)
console.log(then)
Run Code Online (Sandbox Code Playgroud)

为什么now === then

我究竟做错了什么 ?

javascript date momentjs

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

NodeJS:我无法使用connect-redis工作

这是我的代码:

var express = require('express');
var RedisStore = require('connect-redis')(express);
Run Code Online (Sandbox Code Playgroud)

这是我得到的错误:

  RedisStore.prototype.__proto__ = Store.prototype;
                                        ^
TypeError: Cannot read property 'prototype' of undefined
    at module.exports (/home/cherif/Bureau/Twimbee/server/gamma/node_modules/connect-redis/lib/connect-redis.js:96:41)
    at Object.<anonymous> (/home/cherif/Bureau/Twimbee/server/gamma/index.js:2:42)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:902:3
Run Code Online (Sandbox Code Playgroud)

请帮忙

redis node.js express node-redis

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