小编Mas*_*son的帖子

模糊的NSZombie控制台日志

我尝试在谷歌搜索,并在试图弄清楚这意味着什么时,实际上没有结果.我的控制台正在记录:

objc[17048]: Class _NSZombie_GEOLatLng is implemented in both ?? and ??. One of the two will be used. Which one is undefined.
objc[17048]: Class _NSZombie_GEOLatLng is implemented in both ?? and ??. One of the two will be used. Which one is undefined.
objc[17048]: Class _NSZombie_GEOLocation is implemented in both ?? and ??. One of the two will be used. Which one is undefined.
objc[17048]: Class _NSZombie_GEOLocation is implemented in both ?? and ??. One of the two will be …
Run Code Online (Sandbox Code Playgroud)

iphone console nszombie ios

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

更改iOS键盘动画时间

有没有办法改变iOS键盘动画的时间?

keyboard animation duration ios

8
推荐指数
1
解决办法
3551
查看次数

hrtimer在Linux内核中重复任务

我的目标是使用hrtimerstruct 在linux内核中创建一个重复的任务.我希望它每500毫秒重复一次.

但是,我hrtimer对linux内核的工作方式有点困惑(参见参考资料linux/hrtimer.h).我知道时间是指定的,回调应该返回HRTIMER_RESTART或者HRTIMER_NORESTART.我在网上找到了一些资料,说明需要使用该hrtimer_forward方法在回调中重置计时器.然而,我所看到的消息来源对于如何增加时间有点不清楚.这是我到目前为止的代码:

static struct hrtimer timer;

static enum hrtimer_restart timer_callback(struct hrtimer *timer)
{
    printk(KERN_ERR "Callback\n");
    //I know something needs to go here to reset the timer
    return HRTIMER_RESTART;
}

static int init_timer(void)
{   
    ktime_t ktime;
    unsigned long delay_in_ms = 500L;
    printk(KERN_ERR "Timer being set up\n");

    ktime = ktime_set(0,delay_in_ms*1E6L);
    hrtimer_init(&timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);

    timer.function = &timer_callback;
    printk(KERN_ERR "Timer starting to fire\n");
    printk(KERN_ERR "in %ldms %ld\n", delay_in_ms, jiffies);

    hrtimer_start(&timer, ktime, …
Run Code Online (Sandbox Code Playgroud)

timer callback linux-kernel

8
推荐指数
1
解决办法
2万
查看次数

Rails db:迁移中止...不确定为什么或如何解决它

所以我对Rails真的很新,而且我得到了一个我不理解的奇怪错误.我创建了一个Event模型,我想将它迁移到我的数据库.但是,当我运行时,bundle exec rake db:migrate --trace这就是我得到的:

05:55 PM movienights: bundle exec rake db:migrate --trace
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Invoke rails_env (first_time)
** Execute rails_env
** Execute db:load_config
** Execute db:migrate
==  CreateEvents: migrating ===================================================
-- create_table(:events)
rake aborted!
An error has occurred, all later migrations canceled:

    undefined method `name' for #<ActiveRecord::ConnectionAdapters::TableDefinition:0x007ffa75a27660>
    Documents/Homework/College/2011-2012/Rails/RailsApps/movienights/db/migrate/20120331213639_create_events.rb:4:in `block in change'
    .rvm/gems/ruby-1.9.2-p318/gems/activerecord-3.2.2/lib/active_record/connection_adapters/abstract/schema_statements.rb:160:in `create_table'
    .rvm/gems/ruby-1.9.2-p318/gems/activerecord-3.2.2/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:432:in `create_table'
    .rvm/gems/ruby-1.9.2-p318/gems/activerecord-3.2.2/lib/active_record/migration.rb:450:in `block in method_missing'
    .rvm/gems/ruby-1.9.2-p318/gems/activerecord-3.2.2/lib/active_record/migration.rb:424:in `block in say_with_time' …
Run Code Online (Sandbox Code Playgroud)

ruby rake ruby-on-rails rails-migrations

7
推荐指数
1
解决办法
3405
查看次数

有没有办法从流程的task_struct中找出用户拥有流程的内容?

我有一个task_struct *通过电话得到的find_task_by_vpid(get_pid()).我想找出用户拥有该进程的内容,以便我可以在我正在编写的系统调用中进行一些权限检查,但查看task_struct源代码并没有多大帮助.唯一看起来有用的是loginuid,但由于某种原因,如果我试图像这样访问它,内核将无法编译:my_task_struct->loginuid.是否有另一种方法可以让用户调用该进程task_struct

permissions multithreading pid process linux-kernel

7
推荐指数
1
解决办法
2123
查看次数

从app delegate获取当前视图控制器(可以使用模态)

我知道要从app delegate获取当前视图控制器,我可以使用navigationController我为我的应用程序设置的属性.但是,在我的应用程序的许多地方都可以提供模态导航控制器.有没有办法从app委托中检测到这个,因为当前导航控制器将与app委托持有引用的导航控制器不同?

delegates objective-c ios appdelegate

7
推荐指数
3
解决办法
3万
查看次数

AFNetworking在post请求的JSON参数中发送数组

我正在尝试通过POST将参数发送到我的服务器,它通常可以正常工作,但我无法弄清楚如何发送包含数组的JSON作为参数之一.这是我尝试过的:

AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:[NSURL URLWithString:myURL]];
NSMutableArray *objectsInCart = [NSMutableArray arrayWithCapacity:[_cart count]];
for(NSDictionary *dict in _cart)
{
    NSObject *object = [dict objectForKey:@"object"];
    NSDictionary *objectDict = @{@"product_id": [NSString stringWithFormat:@"%d",[object productID]],
                                 @"quantity": [NSString stringWithFormat:@"%d", [[dict objectForKey:@"count"] intValue]],
                                 @"store_id": [NSString stringWithFormat:@"%d", [Store getStoreID]],
                                 @"price": [NSString stringWithFormat:@"%.2f", [object price]]};
    [objectsInCart addObject:objectDict];
}
NSError *error = nil;
NSString *cartJSON = [[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:objectsInCart
                                                                                    options:NSJSONWritingPrettyPrinted
                                                                                      error:&error]
                                           encoding:NSUTF8StringEncoding];

if(error)
{
    NSLog(@"Error serializing cart to JSON: %@", [error description]);
    return;
}

NSDictionary *parameters = @{@"status": …
Run Code Online (Sandbox Code Playgroud)

arrays post json ios afnetworking

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

核心数据:无法加载名为"CDAccount"的类

我最近下载了iOS 8,以确保我现有的应用程序正常运行,但是我在启动时在调试器中收到警告:

"CoreData: warning: Unable to load class named 'CDAccount' for entity 'CDAccount'.  
Class not found, using default NSManagedObject instead."
Run Code Online (Sandbox Code Playgroud)

经过一些研究,似乎人们在Swift中使用Core Data时遇到了类似的问题,但我的所有代码都在Objective-C中(并且数据模型至少在6个月内没有变化).

任何建议都非常感谢,一旦人们开始升级到iOS 8,我真的很紧张我的应用程序无法正常运行!

core-data objective-c nsmanagedobject ios ios8

6
推荐指数
2
解决办法
7291
查看次数

使协议中的方法不可用

假设我正在创建一个带有自定义初始化程序的协议,我希望我的某些模型对象符合它.

@protocol SomeProtocol <NSObject>
- (instancetype)initWithContext:(Context *)context;
@end
Run Code Online (Sandbox Code Playgroud)

在这样做时,我也希望-[NSObject init]无法使用.我过去完成的方式是在标题中声明类似的内容:

- (instancetype)init NS_UNAVAILABLE;

要么:

- (instancetype)init __attribute__((unavailable("Use -initWithContext:")));

有没有办法在协议中包含类似上面的内容,以便符合此协议的任何类都将使其默认初始化方法不可用?

为了明确,我想知道以下内容是否有效:

@protocol SomeProtocol <NSObject>
- (instancetype)initWithContext:(Context *)context;
- (instancetype)init __attribute__((unavailable("Use -initWithContext:")));
@end
Run Code Online (Sandbox Code Playgroud)

protocols objective-c nsobject ios

6
推荐指数
0
解决办法
540
查看次数

使用函数内的函数进行Big-O分析

我很困惑Big-O在处理函数内的函数时的工作原理(分析最坏情况时).例如,如果你有类似的东西怎么办?

for(int a = 0; a < n; a++)
{
    *some function that runs in O(n*log(n))*
    for(int b = 0; b < n; b++)
    {
        *do something in constant time*
    }
}
Run Code Online (Sandbox Code Playgroud)

这整个块是否会在O(n ^ 2*log(n))中运行,因为在第一个for循环中,你有一个O(n)和一个O(n*log(n)),所以O(n*log (n))更大,因此我们采取的是什么?或者它是O(n ^ 3*log(n))因为你在外部for循环中有一个O(n)和一个O(n*log(n))?

任何帮助表示赞赏!谢谢!

algorithm performance big-o

5
推荐指数
2
解决办法
1262
查看次数