我有一个rails项目,我认为它是以root身份创建的.我想更改权限,以便所有者不是root用户,而是我的用户.
我在stackoverflow上找到了一个命令来实现这个目的.
sudo chown -R $(username):$(username) Directoryname
Run Code Online (Sandbox Code Playgroud)
所以要更改它以便我的用户拥有它我运行这个:
sudo chown -R $(Jack):$(Jack) APIClient
Run Code Online (Sandbox Code Playgroud)
但是我得到错误:
sudo: chown: command not found
Run Code Online (Sandbox Code Playgroud)
如果我只是在没有sudo的情况下运行chown,我得到:
zsh: command not found: chown
Run Code Online (Sandbox Code Playgroud)
有谁知道如何解决这个问题?我想这可能与我的zsh有关但不确定.
谢谢你的帮助.
我在登录后试图从我的iOS应用程序中的JSON响应对象获取数据.但我仍然收到此错误.
错误:
'NSInvalidArgumentException', reason: '-[__NSCFArray objectForKeyedSubscript:]: unrecognized selector sent to instance 0x8fc29b0'
Run Code Online (Sandbox Code Playgroud)
这是我的请求代码,我正在使用AFNetworking:
self.operation = [manager GET:urlString parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSDictionary *JSON = (NSDictionary *)responseObject;
NSDictionary *user = JSON[@"user"];
NSString *token = user[@"auth_token"];
NSString *userID = user[@"id"];
// NSString *avatarURL = user[@"avatar_url"];
// weakSelf.credentialStore.avatarURL = avatarURL;
weakSelf.credentialStore.authToken = token;
weakSelf.credentialStore.userId = userID;
weakSelf.credentialStore.username = self.usernameField.text;
weakSelf.credentialStore.password = self.passwordField.text;
[SVProgressHUD dismiss];
[self dismissViewControllerAnimated:YES completion:nil];
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
if (operation.isCancelled) {
return;
}
[SVProgressHUD showErrorWithStatus:@"Login Failed"]; …Run Code Online (Sandbox Code Playgroud) 我的 ios 项目中有一个按钮,如果用户是当前用户,则显示编辑配置文件,如果用户不是当前用户,则显示。
我正在根据上述条件以编程方式设置 titleLabel 文本。我还以编程方式将按钮文本设置为居中对齐。
我遇到的问题是它非常适用于编辑配置文件按钮,因为它应该居中对齐,但是当显示跟随按钮时,跟随这个词稍微偏离了左边的中心,我不知道我要去哪里错误的。
这是我的代码:
if([userID isEqualToString:credentialID]){
self.followEditBtn.layer.cornerRadius = 2;
self.followEditBtn.layer.borderColor = UIColorFromRGB(0xA6B9C1).CGColor;
self.followEditBtn.layer.borderWidth = 1.0f;
self.followEditBtn.layer.backgroundColor = UIColorFromRGB(0xF8FBFC).CGColor;
self.followEditBtn.titleLabel.textColor = UIColorFromRGB(0xA1B1C3);
self.followEditBtn.titleLabel.text = @"Edit Profile";
self.followEditBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
} else {
self.followEditBtn.layer.cornerRadius = 2;
self.followEditBtn.layer.borderColor = UIColorFromRGB(0x19A548).CGColor;
self.followEditBtn.layer.borderWidth = 1.0f;
self.followEditBtn.layer.backgroundColor = [UIColor whiteColor].CGColor;
self.followEditBtn.titleLabel.textColor = UIColorFromRGB(0x19A548);
self.followEditBtn.titleLabel.text = @"Follow";
self.followEditBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
}
Run Code Online (Sandbox Code Playgroud)
您可以看到以下按钮的一些图像稍微偏离左侧的中心,但编辑配置文件按钮正确对齐:


当我尝试将对象添加到可变数组时,我不断收到无法识别的选择器,当在表视图中选择单元格时,我尝试向可变数组添加和删除项目,这是我的代码:
@interface SomeViewController
@property (nonatomic, strong) NSMutableArray *selectedItems;
@end
Run Code Online (Sandbox Code Playgroud)
查看已加载:
-(void)viewDidLoad {
[super viewDidLoad];
self.selectedItems = [[NSMutableArray alloc] init];
}
Run Code Online (Sandbox Code Playgroud)
选择单元格:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
MyCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
[self.selectedItems addObject:[NSString stringWithFormat:@"%@", cell.contactID]];
Run Code Online (Sandbox Code Playgroud)
MyCell 文件上的联系人 ID 属性为:
@property (strong, nonatomic) NSString *contactID;
Run Code Online (Sandbox Code Playgroud)
我不断收到此错误:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayM _fastCStringContents:]: unrecognized selector sent to instance 0x7fc3dd1091b0'
Run Code Online (Sandbox Code Playgroud) ios ×3
command-line ×1
nsarray ×1
nsstring ×1
objective-c ×1
terminal ×1
uibutton ×1
uitableview ×1