小编uas*_*asi的帖子

KVO:+ keyPathsForValuesAffecting <Key>不能与NSObjectController的(子类)一起使用

我有一个KVO-able类(称之为Observee),其affectedValue动态属性受affectingValue属性影响.属性之间的依赖关系由实现+keyPathsForValuesAffectingAffectedValue方法定义.

设置一个值以affectingValue通知affectedValue 已按我的预期更改, 除非 Ovservee是它的子类NSObjectController.完整示例如下:

@interface Observee : NSObject // or NSObjectController
@property (readonly, strong, nonatomic) id affectedValue;
@property (strong, nonatomic) id affectingValue;
@property (strong, nonatomic) NSArrayController *arrayController;
@end

@implementation Observee

@dynamic affectedValue;
- (id)affectedValue { return nil; }

+ (NSSet *)keyPathsForValuesAffectingAffectedValue {
  NSLog(@"keyPathsForValuesAffectingAffectedValue called");
  return [NSSet setWithObject:@"affectingValue"];
}

@end

@interface AppDelegate : NSObject <NSApplicationDelegate>
@property (strong, nonatomic) Observee *observee;
@end

@implementation AppDelegate

- (void)applicationDidFinishLaunching:(NSNotification *)notification …
Run Code Online (Sandbox Code Playgroud)

cocoa objective-c key-value-observing nsarraycontroller nsobjectcontroller

5
推荐指数
1
解决办法
1840
查看次数

bash中的“ exec some_cmd&”是什么意思

exec some_cmd &此脚本中找到了一个用法:

...
exec elixir \
  -pa _build/prod/consolidated \
  --no-halt \
  --erl "+A$THREAD_COUNT" \
  --erl "+K true" \
  --erl "-smp auto" \
  --erl "+scl false" \
  --erl "+spp true" \
  --erl "+swt low" \
  --erl "+sbwt long" \
  --sname $NODE \
  --cookie $COOKIE \
  -S mix run \
    --no-compile \
$@ \
&
...
Run Code Online (Sandbox Code Playgroud)

exec some_cmd用替换外壳some_cmd。在后台作为子进程some_cmd &生成some_cmd。那么将它们结合在一起会发生什么呢?

我尝试了bash 3.2,结果表明它看起来像是在生成一个后台进程:

# script
echo "Shell PID: $$"
exec sh -c …
Run Code Online (Sandbox Code Playgroud)

bash

4
推荐指数
1
解决办法
237
查看次数