微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决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 举报,一经查实,本站将立刻删除。