English 中文(简体)
Rubymotion ─ ─ 我如何将变量作为特定类型?
原标题:RubyMotion >> How do I Cast a Variable as a Particular Type?

由于 RubyMotion 似乎在编译时做了很多类型转换, 我很难将正确的数据类型转换成 NSMutablurL request POST 请求。 它期待 NSData, 但我无法找到如何将 NSData 的变量输入到 NSData 中而不丢弃错误 。 没有打字, 我们的 SOAP 服务器无法正确接收数据, 我得到可怕的( 模糊的) “ 根层的数据无效 。 第一行, 位置 1 错误 。 ”

<强> 这是有问题的行:

postXML = "<xml><whatever>hey</whatever></xml>"
postData = ( postXML as NSData ).dataUsingEncoding( NSUTF8StringEncoding, allowLossyConversion: true );

request = NSMutableURLRequest.alloc.init
request.setURL( NSURL.URLWithString( "https://services.sbx1.cdops.net/v4.3/SubscriberServicePox.svc/Login" ) )
request.setHTTPMethod( "POST" )

request.setValue( "application/xml", forHTTPHeaderField: "Content-Type" )
request.setHTTPBody( postData, dataUsingEncoding:NSUTF8StringEncoding )

theConnection = NSURLConnection.alloc.initWithRequest( request, delegate:self )

任何帮助都将不胜感激。

最佳回答
问题回答

暂无回答




相关问题
List Contents of Directory in a UITableView

I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...

iPhone NSUserDefaults persistance difficulty

In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Resize UIImage with aspect ratio?

I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...

Allowing interaction with a UIView under another UIView

Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...

热门标签