小编bil*_*.ss的帖子

如何将Int值添加到Alamofire上传参数

我想为以下内容增加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为参数添加值?

int json nsdata swift alamofire

9
推荐指数
1
解决办法
4353
查看次数

tableView.rx.itemSelected中的RxSwift双映射

我想从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)

我在某处展示了这种可能性,但无法回忆起它.你知道怎么做吗?

uitableview ios rx-swift rx-cocoa

7
推荐指数
2
解决办法
8069
查看次数

iOS-Universal-Framework安装问题

我尝试安装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)

shell xcode ios telegram osx-elcapitan

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

RxSwift将Observable <Bool>转换为Observable <Void>

我对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)

generics sequence ios swift rx-swift

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