任何人都可以幫助我將以下Java代碼轉換爲Objective-C代碼。我知道Objective-C,但我無法將此代碼轉換爲Objective-C。將Java代碼轉換爲Objective-C代碼?
這是Java代碼。
public MyList RecReverse() { //my attempt at the recursive method
if (head.getNext() == null) {
return this;
}
MyList remainder = new MyList();
remainder.head = head.getNext(); // New list has rest of this list (after head)
ListNode temp = new ListNode(head.getString()); // save the first thing in list
remainder = remainder.RecReverse(); //reverse the things in the new 2nd part list
remainder.end().setNext(temp); // put old head on the end
return remainder;
}
private ListNode end() {
ListNode curr = head;
while (curr.getNext() != null) {
curr = curr.getNext();
}
return curr;
}
感謝
我下載了一個工具j2objc-master,我試圖解決它,但沒有用。 –
看起來像這個代碼「嘗試」恢復鏈接列表的順序。爲什麼不使用API中包含的東西?你有沒有研究,如果有一些功能呢? – qqilihq
你能解釋一下嗎,所以我可以在我的代碼中做到這一點 –