小编Hus*_*n S的帖子

以编程方式解锁 MAC

我想以编程方式解锁 mac。目前我正在使用苹果脚本来实现这个建议。它工作得很好,但问题是这是一个耗时的过程。执行脚本大约需要 4-5 秒。这是我使用 NSAppleScript 执行的脚本。请建议我如何让它快速工作。或任何其他最快的方式。谢谢

tell me to activate\n
tell application \"System Events\" to keystroke \"PASSWORD\"\n 
tell application \"System Events\" to keystroke return\n 
tell application \"System Events\" to keystroke return"
Run Code Online (Sandbox Code Playgroud)

macos applescript objective-c

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

iOS - 无法使用Twitter/Fabric新SDK上传媒体

我想从我的iOS应用程序发布照片到twitter.我可以在没有媒体的情况下发布推文,但是当我试图附加媒体时,它会抛出错误.

我正在关注Twitter文档,首先我需要将媒体上传到https://upload.twitter.com/1.1/media/upload.json,然后我将能够使用media-id将其附加到推文上.

这是我上传媒体的代码.

应用程序在URLRequestWithMedthod调用时崩溃.

帮我解决问题.

UIImage *image = [UIImage imageNamed:@"shareit.png"];
NSData *imageData = UIImageJPEGRepresentation(image, 0.7);
NSString *statusesShowEndpoint = @"https://upload.twitter.com/1.1/media/upload.json";
NSDictionary *params = @{@"media" : imageData};
NSError *clientError;
NSURLRequest *request = [[[Twitter sharedInstance] APIClient] 
                         URLRequestWithMethod:@"POST"
                         URL:statusesShowEndpoint
                         parameters:params
                         error:&clientError];

if (request) {
    [[[Twitter sharedInstance] APIClient]
     sendTwitterRequest:request
     completion:^(NSURLResponse *response,
                  NSData *data,
                  NSError *connectionError) {
         if (data) {
             // handle the response data e.g.
             NSError *jsonError;
             NSDictionary *json = [NSJSONSerialization
                                   JSONObjectWithData:data
                                   options:0
                                   error:&jsonError];
             NSLog(@"%@",json);
         }
         else {
             NSLog(@"Error: %@", connectionError);
         }
     }]; …
Run Code Online (Sandbox Code Playgroud)

twitter objective-c ios twitter-rest-api

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