我想为以下内容增加Int价值multipartFormData:
Alamofire.upload(.POST,
url,
headers: headers,
multipartFormData: { multipartFormData in
//add some jpg image
//add other vaues:
for (key, value) in parameters {
if value is String {
multipartFormData.appendBodyPart(data: value.dataUsingEncoding(NSUTF8StringEncoding)!, name: key)
} else if value is Int {
let convertedValueNumber: NSNumber = NSNumber(int: value.intValue)
let data = NSKeyedArchiver.archivedDataWithRootObject(convertedValueNumber)
multipartFormData.appendBodyPart(data: data, name: key)
}
}
}, encodingCompletion: { encodingResult in
//some processing
})
Run Code Online (Sandbox Code Playgroud)
但服务器返回错误,我不发送Int值.如何Int为参数添加值?
我想从tableView.rx.itemSelected处理过程中获取对象.这个方法返回IndexPath,所以我可以映射这个值.但是如何从索引中获取对象ViewModel?
struct ViewModel {
var items: Observable<[Item]>
}
Run Code Online (Sandbox Code Playgroud)
近似我期待这样的事情(但这个流程是错误的):
tableView.rx.itemSelected
.map { indexPath -> Item in
return viewModel.items.map {$0[indexPath.row]}
}
..subscribe(onNext: { [unowned self] item in
//other actions with Item object
})
.disposed(by: disposeBag)
Run Code Online (Sandbox Code Playgroud)
我在某处展示了这种可能性,但无法回忆起它.你知道怎么做吗?
我尝试安装iOS-Universal-Framework.尝试从此存储库运行instalation shell screept并始终获取消息:
iOS Real Static Framework Installer
===================================
This will install the iOS static framework templates and support files on your computer.
Note: Real static frameworks require two xcspec files to be added to Xcode.
*** THIS SCRIPT WILL ADD THE FOLLOWING FILES TO XCODE ***
* Platforms/iPhoneOS.platform/Developer/Library/Xcode/Specifications/UFW-iOSStaticFramework.xcspec
* Platforms/iPhoneSimulator.platform/Developer/Library/Xcode/Specifications/UFW-iOSStaticFramework.xcspec
Where is Xcode installed? (CTRL-C to abort) [ /Applications/Xcode.app/Contents/Developer ]:
Could not find Xcode files in "/Applications/Xcode.app/Contents/Developer". Please make sure you typed it correctly.
You …Run Code Online (Sandbox Code Playgroud) 我对RxSwift并不那么信服,而且很难理解.在审查了不同的材料之后,我仍然无法工作和操纵序列.总的来说,我有类型转换的问题:
Cannot convert return expression of type 'Observable<Bool>' to return type 'Observable<Void>' (aka 'Observable<()>')
Run Code Online (Sandbox Code Playgroud)
我有CocoaAction处理,应该返回 Observable<Void>
func stopProject() -> CocoaAction {
return CocoaAction { _ in
let stopProject = stop(project: self.projectId)
return stopProject.asObservable() //wrong converting
}
}
Run Code Online (Sandbox Code Playgroud)
该stop函数返回Observable<Bool>
完成视图:
return stop(project: self.projectId).flatMap { _ in
Observable<Void>.empty()
}
Run Code Online (Sandbox Code Playgroud)