Restkit:本机 iOS Swift 应用程序在 Xcode 12.5 中崩溃

问题描述

public class HostingGameActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_hosting_game); FirebaseAuth mAuth = FirebaseAuth.getInstance(); AtomicBoolean startGame = new AtomicBoolean(false); BackgroundTasks taskExecutor = new BackgroundTasks(); Button startGame_button = findViewById(R.id.startGame_button); startGame_button.setBackground(new ColorDrawable(Color.GRAY)); updateDataInBackground(startGame,taskExecutor,mAuth); startGame_button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if(startGame.get()){ Intent start_game_intent = new Intent(HostingGameActivity.this,MapsActivity.class); startActivity(start_game_intent); taskExecutor.shutdown(); } } }); } void updateDataInBackground(AtomicBoolean startGame,BackgroundTasks taskExecutor,FirebaseAuth mAuth) { BackgroundTasks.executor.execute(()->{ List<String> host_data_request = taskExecutor.getRequest(mAuth.getUid(),Requests.Host_Data); while(!startGame.get()) { try { startGame.set(updateText(host_data_request)); host_data_request = taskExecutor.getRequest(mAuth.getUid(),Requests.Host_Data); } catch (ExecutionException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } } }); } boolean updateText(List<String> host_data_request) throws ExecutionException,InterruptedException { Future<Boolean> result = BackgroundTasks.executor.submit(()-> { //get views and buttons Button startGame_button = findViewById(R.id.startGame_button); TextView players_counter_text = findViewById(R.id.player_counter_text); TextView players_display_text = findViewById(R.id.players_display_text); //extract You text String you_text = players_display_text.getText().toString().substring(0,3); StringBuilder builder = new StringBuilder(); //count players connected int player_counter = 1; //clear text and set it new text to the view builder.append(you_text + "\n"); if(host_data_request != null) { for (String playerName : host_data_request) { player_counter++; System.out.println(playerName); String[] row_values = playerName.split(" "); builder.append(row_values[1]).append("\n"); } players_display_text.setText(builder.toString()); } players_counter_text.setText("Players: " + player_counter); if(player_counter > 5) { //set Button color if the game can start startGame_button.setBackground(new ColorDrawable(Color.GREEN)); return true; } return false; }); return result.get(); } 尝试映射属性值时,它会抛出异常:

MKMapperOperation

enter image description here

代码 11.xx 运行良好。当我更新到 Xcode 12 时崩溃开始了。

我尝试了以下但没有运气:

RestKit RKObjectMapping Swift Optional

我也在 Restkit git repo 上创建了以下问题。但从那里没有运气:

https://github.com/RestKit/RestKit/issues/2562

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)