我有自己的类来进行http调用但现在在iOS9中这个方法已被弃用:
[NSURLConnetion sendAsynchronousRequest:queue:completionHandler:]
我正在尝试测试新的
[NSURLSession dataTaskWithRequest:completionHandler:]
但Xcode给出错误,因为它没有找到这种方法.
不推荐使用Xcode编译器警告:
'sendAsynchronousRequest:queue:completionHandler:' is deprecated: first deprecated in iOS 9.0 - Use [NSURLSession dataTaskWithRequest:completionHandler:] (see NSURLSession.h
Run Code Online (Sandbox Code Playgroud)
新方法出错:
No known class method for selector 'dataTaskWithRequest:completionHandler:'
Run Code Online (Sandbox Code Playgroud)
方法:
-(void)placeGetRequest:(NSString *)action withHandler:(void (^)(NSURLResponse *response, NSData *data, NSError *error))ourBlock {
NSString *url = [NSString stringWithFormat:@"%@/%@", URL_API, action];
NSURL *urlUsers = [NSURL URLWithString:url];
NSURLRequest *request = [NSURLRequest requestWithURL:urlUsers];
//[NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:ourBlock];
[NSURLSession dataTaskWithRequest:request completionHandler:ourBlock];
}
Run Code Online (Sandbox Code Playgroud)
任何的想法?
在所有测试开始之前我必须执行一些代码.所以我需要使用QUnit钩子,before但在ember-qunit唯一可用的回调中是beforeEach和afterEach.
我该怎么做?
我已经实现了一个系统来重新排序我的UITableViews中的单元格.一切都很好,除了我不能将细胞重新排序到iPhone屏幕上没有显示的位置.
所以我已经实现了一个条件来检查我是否需要滚动
NSArray *indexVisibles = [_tableView indexPathsForVisibleRows];
NSInteger indexForObject = [indexVisibles indexOfObject:indexPath];
if (indexForObject == NSNotFound){
[_tableView scrollToRowAtIndexPath:indexPath
atScrollPosition:UITableViewScrollPositionTop
animated:YES];
}
Run Code Online (Sandbox Code Playgroud)
我的问题是动画不甜而干净.
我认为检查一个单元格是否显示的操作对于我的系统来说是非常巨大的,并且当我移动单元格时会产生一个小延迟,但是,我也不确定为什么当单元格隐藏时滚动是如此困难.
我已经改变UITableViewScrollPositionTop了UITableViewScrollPositionMiddle,现在它更好但是速度非常大所以总是滚动到我的UITableView的顶部.
我想慢慢来.
其他失败尝试:
选项1:
[UIView animateWithDuration:0.2
animations:^{_tableView.contentOffset = CGPointMake(0.0, _tableView.contentOffset.y - 50);}
completion:^(BOOL finished){ }];
Run Code Online (Sandbox Code Playgroud)
但这有两个问题:
选项2:
[UIView animateWithDuration: 1.0
animations: ^{
[_tableView scrollToRowAtIndexPath:indexPath
atScrollPosition:UITableViewScrollPositionMiddle
animated:NO];
}completion: ^(BOOL finished){
}
];
Run Code Online (Sandbox Code Playgroud) 我正在生成一个XML文件来进行付款,我对用户的全名有约束.那个参数只接受字母字符(a-ZAZ)+空格来分隔姓名和姓氏.
我无法以简单的方式过滤这个,我如何构建正则表达式或过滤器以获得我想要的输出?
例:
'Carmen López-Delina Santos' 一定是 'Carmen LopezDelina Santos'
我需要用单个元音转换带有装饰的元音,如下所示:á> a,à> a,a,等等; 并删除点,连字符等特殊字符.
谢谢!
我刚刚成功地在独立模式下安装了docker-registry,我可以使用以下命令
curl -X GET http://localhost:5000/v2/
Run Code Online (Sandbox Code Playgroud)
得到正确的结果.
但是,当我使用时
curl -X DELETE http://localhost:5000/v2/<name>/blobs/<digest>
Run Code Online (Sandbox Code Playgroud)
删除一个图层,它失败了,我得到:
{"errors":[{"code":"UNSUPPORTED","message":"The operation is unsupported."}]}
Run Code Online (Sandbox Code Playgroud)
我使用docker hub的默认配置.我研究了官方配置但未能解决它.
我怎么能把它弄出来?
我想知道在mozilla firefox中是否有任何附加组件来重定向URL。在Google Chrome浏览器中有一个附加组件Switcheroo。我在mozilla firefox中需要这样的网址切换器。我已经尝试过使用mozilla的重定向URL附加组件。但是它不能正确重定向。
要求:
我需要测试localhost门户页面。但是在少数地方,开发环境的URL是硬编码的。我想将这些URL重定向到localhost以测试我在本地所做的更改。
例如重定向:
protocol://dev_hostname:dev_portnubmer/wps/portal/abcd/xyz/u!/abcd
应该重定向到
protocol://localhost:localhostPortnumber/wps/portal/abcd/xyz/u!/abcd
对于google chrome switcheroo加载项中的此重定向,我已配置如下:-http:// dev_hostname:dev_portnubmer ---> http:// localhost:localhostPortnumber。该附件可更改协议,域名,端口号。它没有更改url部分的其余部分。如我所料,它的运作良好。但是在Mozilla中,我需要这样的插件。
我在iOS7中遇到推送通知问题.
我已经为iOS6开发了一个应用程序,并且推送通知非常有效.但是,当我将该应用程序放在iOS7设备中时,它不会运行.
但是很奇怪的事情发生了.如果我使用开发键,我的iOS7设备可以接收推送,但是使用生产键,它不能.
我可以获得我的devide令牌,但它无法接收任何东西.
任何的想法?
这是我的代码:
Appdelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// PUSH-CODE
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
....
}
// PUSH-CODE
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
NSString *token = [[deviceToken description] stringByTrimmingCharactersInSet: [NSCharacterSet characterSetWithCharactersInString:@"<>"]];
token = [token stringByReplacingOccurrencesOfString:@" " withString:@""];
NSLog(@"Token: %@", token);
[[NSUserDefaults standardUserDefaults] setObject:token forKey:@"deviceToken"];
[[NSUserDefaults standardUserDefaults] synchronize];
}
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
{
NSLog(@"Failed to get token, error: %@", error);
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用capistrano 3将我的ruby on rails 4项目部署到我的服务器中,但是我遇到了一些错误.
首先,当我这样做的时候
cap production deploy:check
Run Code Online (Sandbox Code Playgroud)
一切看起来都好!但是,当我这样做
cap production deploy
Run Code Online (Sandbox Code Playgroud)
我有两个错误:
DEBUG [e3cf53e3] Running [ -L /var/www/myapp/releases/20131026111326/public/assets ] on mydomain.com
DEBUG [e3cf53e3] Command: [ -L /var/www/myapp/releases/20131026111326/public/assets ]
DEBUG [e3cf53e3] Finished in 0.104 seconds with exit status 1 (failed).
DEBUG [304388e5] Running [ -d /var/www/myapp/releases/20131026111326/public/assets ] on mydomain.com
DEBUG [304388e5] Command: [ -d /var/www/myapp/releases/20131026111326/public/assets ]
DEBUG [304388e5] Finished in 0.104 seconds with exit status 1 (failed).
Run Code Online (Sandbox Code Playgroud)
我得到的最后一个错误是:
DEBUG [4e4c65ef] rake aborted!
DEBUG [4e4c65ef] Unknown …Run Code Online (Sandbox Code Playgroud) 我正在使用PlayFramework 2.2.2,我非常有兴趣知道是否可以在不同的文件中记录我的应用程序以及如何操作.
我想为不同的控制器提供不同的文件,而不是针对不同的级别.
我已经测试它将conf/application-logger.conf中的几个文件名混合起来作为Play的官方文档,但我找不到任何方法来做到这一点.
我正在尝试在我的WatchKit应用程序中显示圆形图像,但我没有找到任何方法以编程方式执行它.
我做了什么,它是使用我的原始图像作为一组背景,并放入一个圆形的掩模图像,但我认为这不是那么干净.
我想到的另一个不同的解决方案是在我的后端创建一个新的缩略图或类似我想要显示的形状,但这需要更多的时间来编程.
我也可以使用WKInterfaceGroup中的radius参数,但在我的情况下(见下图),我将失去我在角落里的通知气泡.
我的app界面:

优步应用示例:

如果我有一个元组列表,第一个是数字,第二个是字符串,例如:
[(2, 'eye'), (4, 'tail'), (1, 'scarf'), (4,'voice')]
Run Code Online (Sandbox Code Playgroud)
如何按数字降序排序,如果在任何点都有数字,那么具有相同数字的单词应按字母顺序排序.并返回最终排序的单词.
从我的例子来看:
['tail', 'voice', 'eye', scarf']
Run Code Online (Sandbox Code Playgroud)
我按降序对它们进行了排序,但我不知道如何按字母顺序对它进行分类.很高兴听到任何暗示和回答.谢谢!
def sorting(list)
my_list = []
for x, y in list.items():
my_list+=[(y,x)]
sort=sorted(my_list, reverse=True)
Run Code Online (Sandbox Code Playgroud) 有没有办法用Objective-C减去两个或更多NSUInteger值?
这是我的代码
__block NSUInteger *removedElementsCount = 0;
__block BOOL lastIsSuperElement = NO;
// Get the elements not collapsed
[_elements enumerateObjectsUsingBlock:^(id __nonnull obj, NSUInteger idx, BOOL * __nonnull stop) {
if (_isHidingSubElementsBlock(obj)){
//_collapseSubCellsAtIndexPathBlock(idx+_elementsOffset);
[elementToRemove addObject:(Task *)obj];
lastIsSuperElement = YES;
[indexPathToRemove addObject:[NSIndexPath indexPathForRow:(idx-removedElementsCount) inSection:0]];
removedElementsCount = 0;
} else if (lastIsSuperElement){
removedElementsCount++;
lastIsSuperElement = NO;
}
}];
Run Code Online (Sandbox Code Playgroud)
当我尝试使用idx-removedElementsCount创建新的NSIndexPath时,出现以下错误:
HTReorderTableCells.m:231:75: Invalid operands to binary expression ('NSUInteger' (aka 'unsigned int') and 'NSUInteger *' (aka 'unsigned int *'))
Run Code Online (Sandbox Code Playgroud)
我找了一个解决方案,但我没找到任何东西.
ios ×5
objective-c ×3
java ×2
apple-watch ×1
capistrano ×1
ember-qunit ×1
ember.js ×1
firefox ×1
ios6 ×1
ios7 ×1
ios9 ×1
javascript ×1
python ×1
python-3.x ×1
qunit ×1
regex ×1
scroll ×1
sorting ×1
string ×1
subtraction ×1
uitableview ×1
watchkit ×1
xcode ×1