在有限的时间内,我想抑制编译器在Xcode 7.3.1中向我展示的这些警告:
<File>: Pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified)
我已将此编译器标志添加到My Target/Build Phases/Compile Sources下的所有类:
-Wnullability-completeness
但它没有用 - 警告仍然显示出来.我怎样才能摆脱警告?
我正在设置UICollectionView的内容插图:
[_collectionView setContentInset:UIEdgeInsetsMake(0.f, 0.f, 100.f, 0.f)];
Run Code Online (Sandbox Code Playgroud)
然后我用这种方法以编程方式一直滚动到UICollectionView的底部:
- (void)scrollToLastMessageAnimated:(BOOL)animated;
{
if (_messages.count == 0) { return; }
NSUInteger indexOfLastSection = _messagesBySections.count - 1;
NSInteger indexOfMessageInLastSection = [_messagesBySections[indexOfLastSection] count] - 1;
NSIndexPath *path = [NSIndexPath indexPathForItem:indexOfMessageInLastSection
inSection:indexOfLastSection];
[_collectionView scrollToItemAtIndexPath:path
atScrollPosition:UICollectionViewScrollPositionCenteredVertically
animated:animated];
}
Run Code Online (Sandbox Code Playgroud)
它向下滚动,但它忽略了contentInset,这意味着最后一个单元格低于指定的内容插入:
左侧图像显示了视图出现后现在的显示方式.在右图中,我手动向下滚动到最后一条消息.
我正在使用AutoLayout,任何想法为什么会发生这种情况?
编辑:
以下是IB设置的屏幕截图:

适用于iOS的Leanplum,Apptimize和其他A/B测试平台能够从Web下载资产(nib文件,图像等)并在运行时替换它们.
天真的方法是下载新资产并将其替换为资源包目录,但由于权限,无法将文件写入资源目录.
问题是,这些A/B测试平台在运行时使用什么技术来替换资产?
编辑:
在读取leanplum静态库文件(使用nm)上的符号后,似乎它们是Swizzling可可文件系统API.
例如:(示例行nm -m leanplum.a)
-[NSBundle(LeanplumExtension) leanplum_URLForResource:withExtension:]
Run Code Online (Sandbox Code Playgroud)
通过使用otool,我可以打印实现:
-[NSBundle(LeanplumExtension) leanplum_URLForResource:withExtension:]:
0000000000000069 pushq %rbp
000000000000006a movq %rsp, %rbp
000000000000006d pushq %r15
000000000000006f pushq %r14
0000000000000071 pushq %r13
0000000000000073 pushq %r12
0000000000000075 pushq %rbx
0000000000000076 subq $0x18, %rsp
000000000000007a movq %rcx, %rbx
000000000000007d movq %rdi, 0xffffffffffffffc8(%rbp)
0000000000000081 movq %rdx, %rdi
0000000000000084 callq _objc_retain
0000000000000089 movq %rax, %r14
000000000000008c movq %rbx, %rdi
000000000000008f callq _objc_retain
0000000000000094 movq %rax, 0xffffffffffffffd0(%rbp)
0000000000000098 movq _originalMainBundle(%rip), %rcx
000000000000009f movq "+[NSBundle(LeanplumExtension) leanplum_mainBundle]"(%rcx), …Run Code Online (Sandbox Code Playgroud) 我正在使用WebStorm来执行一项艰巨的任务.调试器成功停止在Gruntfile.js文件中的断点处,但不在我的任务文件中.
在Gruntfile.js中我注册了这样一个任务:
grunt.initConfig({
... configuration ...
});
grunt.registerTask('myTask', ['mocha:myTask']);
Run Code Online (Sandbox Code Playgroud)
当我在测试'myTask'的相应js文件中设置断点时,它不会停止.我怎样才能调试grunt测试?
所以我尝试了所有可能的解决方案,但它并没有解决我的问题!
我能够调试grunt脚本本身,这是调试器实际停止的地方(在WebStorm或node-inspector中).Gruntfile.js中的断点也正常工作.
问题是,我无法调试实际的Grunt任务本身,用这样的grunt注册:grunt.registerTask('myTask',['mocha:myTask']);
我也可以调试mocha测试本身.但是我想调试一个从grunt任务运行器调用的mocha测试.有任何想法吗?
我需要通过Facebook Graph API从他的公开个人资料中检索Facebook用户的性别.
不幸的是,它并不总是有效.看这些例子:
工作:https: //graph.facebook.com/1423993568
{
"id": "1423993568",
"gender": "male",
...
}
Run Code Online (Sandbox Code Playgroud)
不工作:https: //graph.facebook.com/10152133878666403
{
"error": {
"message": "Unsupported get request. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api",
"type": "GraphMethodException",
"code": 100
}
}
Run Code Online (Sandbox Code Playgroud)
但是,当我直接通过网络打开用户ID时,它可以工作,我甚至可以看到性别.(转到"关于/联系和基本信息")我使用我的个人帐户登录,而不是该用户的朋友! http://www.facebook.com/10152133878666403
问题是什么?这是Facebook的请求或安全功能的问题吗?
更新:
我可以像这样做一个解决方法,但只有当我使用浏览器登录时:
打开此请求时,请获取app_scoped_user_id并从重定向网址获取Facebook用户名:
http://www.facebook.com/app_scoped_user_id/10152133878666403
--> https://www.facebook.com/shiffoni
--> https://graph.facebook.com/shiffoni
Run Code Online (Sandbox Code Playgroud)
收益:
{
"id": "669926402",
"first_name": "Shiffoni",
"gender": "female",
"last_name": "Leonhardt",
"locale": "de_DE",
"name": "Shiffoni Leonhardt",
"username": "shiffoni"
}
Run Code Online (Sandbox Code Playgroud)
获得性别,真实userId或昵称的任何其他想法?
我有一个UICollectionView来显示聊天消息.在开始时,我将现有消息加载到collectionView,并使用此方法将collectionView向下滚动到最后一条消息:
- (void)scrollToLastMessageAnimated:(BOOL)animated;
{
if (_messages.count == 0) { return; }
NSUInteger indexOfLastSection = _messagesBySections.count - 1;
NSInteger indexOfMessageInLastSection = [_messagesBySections[indexOfLastSection] count] - 1;
NSIndexPath *path = [NSIndexPath indexPathForItem:indexOfMessageInLastSection
inSection:indexOfLastSection];
[_collectionView scrollToItemAtIndexPath:path
atScrollPosition:UICollectionViewScrollPositionCenteredVertically
animated:animated];
}
Run Code Online (Sandbox Code Playgroud)
这只在我在viewDidAppear:方法中调用它时才有效,而不是在viewWillAppear:方法中调用.如何在没有动画的情况下向下滚动?
我想在WebStorm中调试我的离子应用程序.我可以在浏览器中运行该应用程序.但我怎么调试?
我试过:ionic serve --debug哪个似乎没有触发任何调试?
如何在浏览器中运行应用程序时调试应用程序?
我正在Google Appengine上运行一个Wordpress网站.它使用GAE插件进行wordpress.媒体库适用于appengine服务器,但不适用于本地服务器.大多数图像也是如此,除非它们具有硬编码链接.我收到了大量的404错误......
http://localhost:8080/_ah/gcs/<BUCKET_NAME>/image.png Failed to load resource: the server responded with a status of 404 (Not Found)
gae服务器上的此链接的工作原理:
http://<BUCKET_NAME>.storage.googleapis.com/image.png
我在本地运行我的应用程序,如下所示:
dev_appserver.py --php_executable_path=/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/php55/php-cgi .
看来谷歌的python脚本没有正确转发链接到实际真正的桶....任何想法?
我使用passport.js + passport-facebook-token来保护我的API构建与Strongloop的Loopback Framework.
为什么护照在成功反序列化后再次序列化反序列化用户?每个请求都会调用passport.authenticate方法!我究竟做错了什么?
这是节点的日志:
deserializeUser, id: XXXXXXXXXXXXXXXX
User found.
serializeUser, id: XXXXXXXXXXXXXXXX
GET /api/events?access_token=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 304 182ms
Run Code Online (Sandbox Code Playgroud)
这是js代码:
passport.use(new FacebookTokenStrategy({
clientID: XXXXXXXXXXXXXXXX,
clientSecret: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXX'
},
function(accessToken, refreshToken, profile, done) {
//check user table for anyone with a facebook ID of profile.id
User.findOne({
'facebookId': profile.id
}, function(err, user) {
if (err) {
return done(err);
}
if (user) {
console.log("User found.");
return done(err, user);
} else {
console.log("User not found.");
User.create({
email: profile.emails[0].value,
facebookId: profile.id,
password: 'secret'
}, function(err, user) { …Run Code Online (Sandbox Code Playgroud) 我在Symfony2网站上使用FOSUserBundle.现在我正在开发一个API,允许通过REST api调用进行注册.
我已经覆盖了FOSUserBundle的RegistrationController:
ApiRegistrationController.php:
/**
* @Route("/user/", defaults = { "_format" = "json" }, requirements = { "_method" = "POST" })
*
*/
public function registerAction(Request $request)
{
[...]
$form = $formFactory->createForm(new ApiRegistrationFormType(), $user);
[...]
}
Run Code Online (Sandbox Code Playgroud)
ApiRegistrationFormType.php:
/**
* @param OptionsResolverInterface $resolver
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'BenMarten\UserBundle\Entity\User',
'intention' => 'registration',
'csrf_protection' => false
));
}
Run Code Online (Sandbox Code Playgroud)
我得到关于错误的CSRF令牌的错误,所以我创建了自己的RegistrationFormType,以禁用CSRF - 但它被调用...
如何仅为api调用实现禁用CSRF令牌?
ios ×4
objective-c ×4
javascript ×2
node.js ×2
php ×2
scroll ×2
webstorm ×2
ab-testing ×1
autolayout ×1
csrf ×1
facebook ×1
gruntjs ×1
ionic ×1
leanplum ×1
passport.js ×1
rest ×1
symfony ×1
wordpress ×1
xcode ×1