小编Lor*_*nzi的帖子

如何在objective-c中创建json

NSData* jsonDataToSendTheServer;

NSDictionary *setUser = [NSDictionary
            dictionaryWithObjectsAndKeys:[@"u" stringByAppendingString:my.id],@"id",
                                        @"GET_USER_INFO",@"command",
                                        @"",@"value",
                                        nil];

 NSLog(@"%@", jsonDataToSendTheServer);
Run Code Online (Sandbox Code Playgroud)

这是我的代码.当我运行上面的代码时,我得到了这个打印

<7b226964 223a2275 35383738 37373334 31222c22 636f6d6d 616e6422 3a224745 545f5553 45525f49 4e464f22 2c227661 6c756522 3a22227d>
Run Code Online (Sandbox Code Playgroud)

我不知道我是否可以创建一个json.

我怎样才能解决这个问题?

json objective-c ios nsjsonserialization

17
推荐指数
2
解决办法
4万
查看次数

迁移AndroidX运行错误android.support.annotation不存在

我只是将项目迁移到AndroidX。同步和构建阶段都可以,但是当我尝试运行编译器时,向我显示此错误:

error: package android.support.annotation does not exist
Run Code Online (Sandbox Code Playgroud)

在生成的文件上出现此错误

// Generated code from Butter Knife. Do not modify!
package com.xdatanet.cda.Adapters;

import android.support.annotation.CallSuper; //<-- Doesn't exists
import android.support.annotation.UiThread; //<-- Doesn't exists
import android.view.View;
import android.widget.ImageView;
import butterknife.Unbinder;
import butterknife.internal.Utils;
import com.xdatanet.cda.CustomView.CDATextView;
import com.xdatanet.cda.R;
import java.lang.IllegalStateException;
import java.lang.Override;

public class CommunicationAdapter$CommunicationViewHolder_ViewBinding implements Unbinder {
  private CommunicationAdapter.CommunicationViewHolder target;

  @UiThread  //<-- First error
  public CommunicationAdapter$CommunicationViewHolder_ViewBinding(CommunicationAdapter.CommunicationViewHolder target,
      View source) {
      // Some generated code
  }

  @Override
  @CallSuper //<-- Second error
  public void unbind() {
      // Some …
Run Code Online (Sandbox Code Playgroud)

java migration mobile android androidx

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

Kotlin null 检查(!!) 当已经检查可空性时

我有一个关于 Kotlin 及其空检查警告的问题。

假设我创建了一个名为“user”的对象,它具有一些属性,如姓名、姓氏等。以下代码是一个示例:

if(user != null) {
    val name = user!!.name
    val surname = user.surname
    val phoneNumber = user.phoneNumber
} else 
    // Something else
Run Code Online (Sandbox Code Playgroud)

为什么,即使我检查该用户不为空,Kotlin 也希望我使用 !! 我第一次打电话给用户?此时它不能为空。

我知道我可以使用以下块,但我不理解这种行为。

user?.let{
    // Block when user is not null
}?:run{
    // Block when user is null
}
Run Code Online (Sandbox Code Playgroud)

android kotlin

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