hello 
student converting java program objective-c. kinda hard, need pass subject.
have little problem regarding ".add" of java. read lot of posts , books understand it. still have hard time understanding.
check if did correct , if can lend me hand in converting. please? thanks.
here java code:
code:
arraylist cid = new arraylist(); arraylist sid = new arraylist(); arraylist<string> sol = new arraylist<string>(); public mainprogram() { initcomponents(); //.add (cartesian product principle) sid.add("sink"); cid.add("1 /x"); here solution in objective-c:
code:
nsarray *cid = [[nsarray alloc]init]; nsarray *sid = [[nsarray alloc]init]; nsmutablearray *sol = [[nsmutablearray array]; (my first trial in .add) cid addobject: @"1/x"; -----but shows error: "expected ';' before 'addobject'" (the other trial is) [sid addobject: @"sink"]; -------but shows error: "local declaration of sid hides instance variable" "nsarray may not respond '-addobject'."
we not homework/assignments you. don't expect give explicit, straight-up answer here. expect people understand enough able yourself.
let's start of 2 thing.
firstly, difference between nsarray , nsmutablearray? if don't know, check out class references @ http://developer.apple.com/library/...oa/reference/foundation/classes/nsarray_class , http://developer.apple.com/library/...rence/foundation/classes/nsmutablearray_class.
if you're going try add object array, think you'll need? type of objects sid , cid pointing to? should be? how them should be?
second how send message (call method) of object in objective-c? what's syntax? how did violate syntax in first attempt?
there's more wrong code this, let's start this.
Forums Macs Mac Programming
- iPhone
- Mac OS & System Software
- iPad
- Apple Watch
- Notebooks
- iTunes
- Apple ID
- iCloud
- Desktop Computers
- Apple Music
- Professional Applications
- iPod
- iWork
- Apple TV
- iLife
- Wireless
No comments:
Post a Comment