我正在尝试按照本教程使用Swift和连接到JSON api NSURLConnection.我可以看到它正在击中网址,但connectionDidFinishLoading似乎没有开火.
import UIKit
class Remote: NSObject {
var host = "http://localhost:3000"
var query = String()
var data: NSMutableData = NSMutableData()
func connect(query:NSString) {
self.query = query
var url = self.document()
var conn = NSURLConnection(request: url, delegate: self, startImmediately: true)
}
func endpoint() -> NSURL {
var query = self.host + self.query
return NSURL(string: query)
}
func document() -> NSURLRequest {
return NSURLRequest( URL: self.endpoint() )
}
func connection(didReceiveResponse: NSURLConnection!, didReceiveResponse response: NSURLResponse!) { …Run Code Online (Sandbox Code Playgroud) 我的TapCell1.swift
这是自定义 UITableViewCell View
import UIKit
class TapCell1: UITableViewCell
{
@IBOutlet var labelText : UILabel
init(style: UITableViewCellStyle, reuseIdentifier: String!)
{
println("Ente")
super.init(style: UITableViewCellStyle.Value1, reuseIdentifier: reuseIdentifier)
}
override func setSelected(selected: Bool, animated: Bool)
{
super.setSelected(selected, animated: animated)
}
}
Run Code Online (Sandbox Code Playgroud)
我的ViewController.swift
它的所有数据源和代理都设置正确.但我的自定义单元格没有显示.
import UIKit
class NextViewController: UIViewController, UITableViewDelegate, UITableViewDataSource
{
@IBOutlet var label: UILabel
@IBOutlet var tableView : UITableView
var getvalue = NSString()
override func viewDidLoad()
{
super.viewDidLoad()
label.text="HELLO GOLD"
println("hello : \(getvalue)")
self.tableView.registerClass(TapCell1.self, forCellReuseIdentifier: "Cell")
}
func tableView(tableView:UITableView!, numberOfRowsInSection …Run Code Online (Sandbox Code Playgroud) 我添加libsqlite3.0.dylib到我的项目,然后我尝试使用以下代码导入:
import UIKit
import sqlite3
class Dataware: NSObject
{
}
Run Code Online (Sandbox Code Playgroud)
但它给了我这个错误:
没有这样的模块'sqlite3'
我开发了一个 iOS 应用程序。出于安全原因,我将所有音频/视频文件下载到Library/Caches下的 Documents 文件夹。
对于使用 iTunes,最终用户不能进行此视频备份。但是一些外部软件可以轻松打开库/缓存并从此文件夹下载所有文件。
我的问题是如何保护此库/缓存文件夹或如何不可见地将文件存储到文档目录。
我创建了2个视图,一个是使用协议和委托.对于第一个视图,不调用Delegate函数.
我的FirstView控制器:我在这里访问代理功能.
import UIKit
class NextViewController: UIViewController,DurationSelectDelegate {
//var secondController: DurationDel?
var secondController: DurationDel = DurationDel()
@IBAction func Next(sender : AnyObject)
{
let nextViewController = DurationDel(nibName: "DurationDel", bundle: nil)
self.navigationController.pushViewController(nextViewController, animated: true)
}
override func viewDidLoad() {
super.viewDidLoad()
secondController.delegate=self
}
func DurationSelected() {
println("SUCCESS")
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
Run Code Online (Sandbox Code Playgroud)
我的SecondView控制器:我在这里创建委托.
import UIKit
protocol DurationSelectDelegate {
func DurationSelected()
}
class DurationDel: UIViewController {
var delegate: DurationSelectDelegate?
@IBAction func Previous(sender …Run Code Online (Sandbox Code Playgroud) 在My Project中,我在UICollectionViewCell中创建了Cell
由于未捕获的异常,它有错误终止应用程序
代码如下.
GalleryCell.swift
class GalleryCell: UICollectionViewCell
{
@IBOutlet var titleLabel : UILabel
init(coder aDecoder: NSCoder!)
{
super.init(coder: aDecoder)
}
}
Run Code Online (Sandbox Code Playgroud)
我在My ViewController中使用了这个单元格:
代码如下:
NextViewController.swift
import UIKit
class NextViewController: UIViewController
{
@IBOutlet var collectionView : UICollectionView
var ListArray=NSMutableArray()
override func viewDidLoad()
{
super.viewDidLoad()
for i in 0..70
{
ListArray .addObject("C: \(i)")
}
}
func collectionView(collectionView: UICollectionView, numberOfItemsInSection section:Int)->Int
{
return ListArray.count
}
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath:NSIndexPath)->UICollectionViewCell
{
var cell = collectionView.dequeueReusableCellWithReuseIdentifier("CELL", forIndexPath: indexPath) as GalleryCell
cell.titleLabel.text="\(ListArray.objectAtIndex(indexPath.item))"
return cell …Run Code Online (Sandbox Code Playgroud) 我正在使用最新的AFNetworking为我的应用程序与REST API服务器说话.
当我500从JSON主体那里得到一些错误时
{ "message": "my error message" },
我无法检索NSErrorlib响应我的消息:
[api setupUser:data success:^(AFHTTPRequestOperation *operation, id responseObject) {
// some success handle
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
// cannot get json response of error :(
}];
Run Code Online (Sandbox Code Playgroud)
你是如何解决它的?
由于我的电脑目前不可用,因此我目前正在使用助手。
我正在尝试导入SlidingMenu(Link)库,但是AIDE似乎不以文件(项目)的形式支持。
我所看到的导入库的都是.jar文件。有人知道我可以在AIDE中导入zip文件吗?谢谢。
ios ×6
swift ×5
android ×1
android-ide ×1
file ×1
file-manager ×1
iphone ×1
json ×1
mobile ×1
nsurlrequest ×1
objective-c ×1
response ×1
slidingmenu ×1
uitableview ×1