小编use*_*152的帖子

在Objective C中创建JSON格式

对于一个应用程序,我想创建一个格式如下所述的JSON,

"Students" : {
    "results": {
        "Grade1": {
            "studentresult": "pass",
            "marksheet": "provided"
        },
        "ID": 01,
        "Name": "Student1", 
    }
}
Run Code Online (Sandbox Code Playgroud)

我使用以下代码创建相同的,

NSMutableDictionary *gradedetails = [[NSMutableDictionary alloc] init];
[gradedetails setObject:@"pass" forKey:@"studentresult"];
[gradedetails setObject:@"provided" forKey:@"marksheet"];

NSMutableDictionary *sdetails = [[NSMutableDictionary alloc] init];
[sdetails setObject:@"01" forKey:@"ID"];
[sdetails setObject:@"Name" forKey:@"Student1"];

NSMutableDictionary *grade = [[NSMutableDictionary alloc] init];
[grade setObject:gradedetails forKey:@"Grade1"];

NSMutableArray *rarray = [[NSMutableArray alloc] init];
[rarray addObject:grade];
[rarray addObject:sdetails];

NSMutableDictionary *results = [[NSMutableDictionary alloc] init];
[results setObject:rarray forKey:@"results"];

NSMutableDictionary *stud = [[NSMutableDictionary alloc] init];
[stud setObject:rdic …
Run Code Online (Sandbox Code Playgroud)

iphone json objective-c nsdictionary ios

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

willSendRequestForAuthenticationChallenge 方法被递归调用

我正在使用 iOS 10。我正在评估自签名证书,如下所示

-(void) connection:(NSURLConnection *)connection willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge {
    NSURLProtectionSpace *protectionSpace = [challenge protectionSpace];

    if ([protectionSpace authenticationMethod] == NSURLAuthenticationMethodServerTrust) {

        SecTrustRef trust = [protectionSpace serverTrust];

        SecPolicyRef policyOverride = SecPolicyCreateSSL(true, (CFStringRef)@"HOSTNAME");
        SecTrustSetPolicies(trust, policyOverride);

        CFMutableArrayRef certificates = CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks);

        /* Copy the certificates from the original trust object */
        CFIndex count = SecTrustGetCertificateCount(trust);
        CFIndex i=0;
        for (i = 0; i < count; i++) {
            SecCertificateRef item = SecTrustGetCertificateAtIndex(trust, i);
            CFArrayAppendValue(certificates, item);
        }

        /* Create a new trust object */
        SecTrustRef newtrust …
Run Code Online (Sandbox Code Playgroud)

ssl ios secure-transport ios10

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

带有参数化触发器插件的 Jenkins 远程构建失败

我正在使用 Jenkins 和参数化触发器插件来远程触发作业。构建触发器失败,控制台输出如下

Server returned HTTP response code: 403 for URL: http://x.x.x.x:8080/job/jobname/buildWithParameters?token=buildcommand&build&delay=0
Connection to remote server failed, waiting for to retry - 10 seconds until next attempt.
Retry attempt #1 out of 5
Server returned HTTP response code: 403 for URL: http://x.x.x.x:8080/job/jobname/buildWithParameters?token=buildcommand&build&delay=0
Connection to remote server failed, waiting for to retry - 10 seconds until next attempt.
ERROR: Remote build failed for the following reason:
Run Code Online (Sandbox Code Playgroud)

http://x.x.x.x:8080/job/jobname/build?token=buildcommand&build&delay=0来自浏览器的带有 URL ' ' 的构建能够远程触发构建。

我只看到两个 URL 之间的区别是一个使用“build”,另一个使用“buildWithParameters”。

你能帮我解决同样的问题吗?

build jenkins jenkins-plugins

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

UICollectionView图像加载问题

UICollectionView用于显示图像.它工作正常.

问题是当我滚动时UICollectionView,一些可见的单元格现在是不可见的,当我向后滚动以便它们再次可见时,我看到它们没有正确显示.

所以发生的imageA是在索引0并且imageB在索引1处.现在在滚动并且在再次加载这些单元格时返回原始滚动位置时,它们的位置被切换或者两个单元具有相同的图像.

原来 :

在此输入图像描述

重新加载单元格后:

在此输入图像描述

代码:

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    MyCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"MyCell"
                                                                          forIndexPath:indexPath];

    DLog(@"url at index %d : %@", indexPath.row, ((MyObject *)[self.list.array objectAtIndex:indexPath.row]).imageUrl);

    MyObject *object = (MyObject *)[self.list.array objectAtIndex:indexPath.row];

    // Get image in separate thread
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{

        // Get image to display
        UIImage * tempImage = object.image;

        if (tempImage)
        {
            // Run code to set image to UIImageView in main thread only.
            dispatch_async(dispatch_get_main_queue(), ^{

                cell.imageView.image …
Run Code Online (Sandbox Code Playgroud)

objective-c ios uicollectionview uicollectionviewcell ios7

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

键盘重叠时向上移动UITextField

在ViewA之上有一个子视图.请在下面找到屏幕布局.当选择UITextField时显示键盘,即使它与UITextField不重叠,视图也会向上滚动.

ViewA
  -> UIButton

subView
  -> UIScrollView
        -> UITextField
        -> UITextField


   ViewA
 -----------
|           |
|           |
|  Button   |
|           |
|           |
 -----------

   subView
 --------------
|              |
|              |
|  UITextField |
|  UITextField |
|              |
 --------------
Run Code Online (Sandbox Code Playgroud)

我已经注册了键盘通知

    - (void) viewWillAppear:(BOOL)animated {

        [[NSNotificationCenter defaultCenter] addObserver:self
                                                 selector:@selector(keyboardDidShow:)
                                                     name:UIKeyboardDidShowNotification
                                                   object:nil];

        [[NSNotificationCenter defaultCenter] addObserver:self
                                                 selector:@selector(keyboardWillBeHidden:)
                                                     name:UIKeyboardWillHideNotification
                                                   object:nil];
    }


- (void) keyboardDidShow:(NSNotification *)notification {

            NSDictionary* info = [notification userInfo];
            CGRect kbRect = [[info objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue];

            UIEdgeInsets contentInsets = UIEdgeInsetsMake(0.0, 0.0, kbRect.size.height, …
Run Code Online (Sandbox Code Playgroud)

iphone objective-c uiscrollview ios autolayout

0
推荐指数
1
解决办法
202
查看次数