说我有一个字符串:
NSString *state = @"California, CA";
Run Code Online (Sandbox Code Playgroud)
有人可以告诉我如何从这个字符串中提取最后两个字符(在本例中为@"CA")
我需要使用ruby 创建HTTP PUT请求.
该请求具有JSON正文
我能够使用以下方法生成JSON主体:
require 'rubygems'
require 'json'
jsonbody = JSON.generate["message"=>"test","user"=>"user1"]
Run Code Online (Sandbox Code Playgroud)
我需要将此PUT请求发送到url:
require 'open-uri'
url = URI.parse('http://www.data.com?access_token=123')
Run Code Online (Sandbox Code Playgroud)
有人可以告诉我如何在Ruby中做到这一点?
我目前有一个API调用,以格式返回给我一个日期/时间: 2010-10-10T07:54:01.878926
我可以假设这是GMT吗?我还将其转换为NSDate对象.有没有办法利用本地iPhone时间重新计算时间?
我正在使用iOS 9 Storyboards来创建一个tvOS应用程序.
该应用程序有一个UICollectionView.我在我的Assets.xcassets集合中定义了一个包含Front,Middle和Back资产的Apple TV图像堆栈.
当用户突出显示UICollectionViewCell时,我希望有一个类似于应用程序图标的"突出显示"效果,用户可以在Siri遥控器上"圈"他们的手指以显示视差效果和光泽.
有人对这个有经验么?
我正在尝试将以下NSString api调用转换为NSURL对象:
http://beta.com/api/token="69439028 "
这是我设置的对象.我用反斜杠转义引号:
NSString *theTry=@"http://beta.com/api/token=\"69439028\"";
NSLog(@"theTry=%@",theTry);
NSMutableURLRequest *url = [[NSURL alloc] URLWithString:theTry];
NSLog(@"url=%@",url);
Run Code Online (Sandbox Code Playgroud)
每次我运行这个,我都会收到这个错误:
2010-07-28 12:46:09.668 RF[10980:207] -[NSURL URLWithString:]: unrecognized selector sent to instance 0x5c53fc0
2010-07-28 12:46:09.737 RF[10980:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSURL URLWithString:]: unrecognized selector sent to instance 0x5c53fc0'
Run Code Online (Sandbox Code Playgroud)
有人可以告诉我如何正确地将此字符串转换为NSURL?
我目前在Ruby中编写了一个基于arc90可读性代码的算法,用于从网页中提取文章.
现在我有了这篇文章,我想从中提取关键字和特定信息(名称,作者等)
虽然它消耗了大量的资源,但我听说Alchemy是一个伟大的红宝石宝石.我可以使用更好的宝石吗?
我目前这段代码用于创建UISearchBar(改编自之前的stackoverflow示例):
UISearchBar *searchBar = [[UISearchBar alloc] initWithFrame:CGRectZero];
[searchBar sizeToFit];
//searchBar.delegate = self;
searchBar.placeholder = @"Search messages, listeners or stations";
self.tableView.tableHeaderView = searchBar;
UISearchDisplayController *searchDC = [[UISearchDisplayController alloc] initWithSearchBar:searchBar contentsController:self];
// The above assigns self.searchDisplayController, but without retaining.
// Force the read-only property to be set and retained.
[self performSelector:@selector(setSearchDisplayController:) withObject:searchDC];
//searchDC.delegate = self;
//searchDC.searchResultsDataSource = self;
//searchDC.searchResultsDelegate = self;
[searchBar release];
[searchDC release];
Run Code Online (Sandbox Code Playgroud)
我需要在工具栏的底部添加3个范围按钮:"主题","消息","工作站",并默认选择第一个.有人可以告诉我该怎么做?
我目前在单元格中定义了一个按钮,以及跟踪其UITouchDown操作的方法,如下所示:
- (void) clickedCallSign:(id)sender {
int index = [sender tag];
NSLog(@"event triggered %@",index);
}
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
//Callsign button
UIButton *button;
CGRect rect = CGRectMake(TEXT_OFFSET_X, BORDER_WIDTH, LABEL_WIDTH, LABEL_HEIGHT);
button = [[UIButton alloc] initWithFrame:rect];
cell.tag=[indexPath row];
button.tag=[indexPath row];
[button addTarget:self action:@selector(clickedCallSign:) forControlEvents:UIControlEventTouchDown];
[button setBackgroundColor:[UIColor redColor]];
[button setTitle:@"hello" forState:UIControlStateNormal];
[cell.contentView addSubview:button];
[button release];
}
Run Code Online (Sandbox Code Playgroud)
但是,当我单击模拟器中的单元格时,控制台调试消息是:"event triggered(null)",我的应用程序很快就崩溃了.
如何正确获取我的clickedCallSign方法中的indexPath.row值?
有人可以告诉我如何在Objective-c中使用ASIHTTPRequest对象来上传UIImage对象吗?我需要将其转换为NSData对象吗?
(这是一个头像上传网址)
E.g.
UIImage *toUpload = [UIImage imageNamed:@"test.jpg"]
URL: "http://www.example.com/api/users/avatar/upload?access_token=12345"
RequestType: PUT
Run Code Online (Sandbox Code Playgroud) 我正在尝试在Amazon EC2上创建一个简单的https服务器以测试第三方API。
这是我遵循的步骤:
openssl genrsa 2048> privatekey.pem
openssl req-新-key privatekey.pem -out csr.pem
openssl x509 -req -days 365 -in csr.pem -signkey privatekey.pem -out server.crt
Run Code Online (Sandbox Code Playgroud)var https = require('https'); var fs = require('fs'); var options = { key: fs.readFileSync('./privatekey.pem'), cert: fs.readFileSync('./server.crt') }; https.createServer(options, function (req, res) { res.writeHead(200); res.end("hello world\n"); }).listen(8080);
当我运行服务器并尝试使用URL https://ec2-XX-XXX-XXX-XXX.compute-1.amazonaws.com/连接到服务器时,我一直拒绝连接。
telnet测试还会产生:
Trying XX.XXX.XXX.XXX...
telnet: connect to address XX.XXX.XXX.XXX: Connection refused
telnet: Unable to connect to remote host
Run Code Online (Sandbox Code Playgroud)
有人可以告诉我在此EC2实例上启用https时需要解决的问题吗?
objective-c ×7
iphone ×6
ruby ×2
amazon-ec2 ×1
data-mining ×1
extract ×1
gem ×1
http-put ×1
httprequest ×1
ios ×1
json ×1
keyword ×1
localization ×1
node.js ×1
nsdate ×1
nsstring ×1
put ×1
scope ×1
selector ×1
ssl ×1
tvos ×1
uibutton ×1
uiimage ×1
uisearchbar ×1
uitableview ×1