stevel05 Expert Licensed User Longtime User Nov 19, 2014 #1 I am trying to implement an ArraySort using sortedArrayUsingComparator: with the NativeObject CreateBlock, it doesn't appear that the sub gets called 'immediately' whichever option I choose for the Delayed parameter. I attach a small example project. Am I trying to implement this correctly? Thanks Attachments AS.zip AS.zip 2.6 KB · Views: 480
I am trying to implement an ArraySort using sortedArrayUsingComparator: with the NativeObject CreateBlock, it doesn't appear that the sub gets called 'immediately' whichever option I choose for the Delayed parameter. I attach a small example project. Am I trying to implement this correctly? Thanks
Erel B4X founder Staff member Licensed User Longtime User Nov 19, 2014 #2 Wait for the next update. It will work with: Code: Test1 = NSArray.RunMethodWithBlocks("sortedArrayUsingComparator:",Array(NSArray.CreateBlock("Sort",2,False))) Upvote 0
Wait for the next update. It will work with: Code: Test1 = NSArray.RunMethodWithBlocks("sortedArrayUsingComparator:",Array(NSArray.CreateBlock("Sort",2,False)))
stevel05 Expert Licensed User Longtime User Nov 24, 2014 #4 Thanks Erel, The sub now runs at the correct time, but no matter what the returned values are, the array data is just returned in reverse order. See attached: Steve Attachments AS1.zip AS1.zip 2.6 KB · Views: 466 Upvote 0
Thanks Erel, The sub now runs at the correct time, but no matter what the returned values are, the array data is just returned in reverse order. See attached: Steve
Erel B4X founder Staff member Licensed User Longtime User Nov 24, 2014 #5 I thoroughly tested it. The problem is that the block created returns an NSObject while the sort method expects a block that returns an int (NSComparisonResult). For now you will not be able to call this method (remember that you can use List.Sort instead). Upvote 0
I thoroughly tested it. The problem is that the block created returns an NSObject while the sort method expects a block that returns an int (NSComparisonResult). For now you will not be able to call this method (remember that you can use List.Sort instead).
stevel05 Expert Licensed User Longtime User Nov 24, 2014 #6 Thanks Erel, I had a feeling that would be the case, I did try writing a library to return an NSComparisonResult, but it wouldn't cast to an Object. Presumably because it's part of an Enum. You were correct when you said that Objective C is more complex than Java. I have an awful lot of learning to do. Now you've implemented SortType in List, I'm sure I can achieve what I wanted using that. It was one of those, do it because you can experiments (or can't in this case). Experimenting is how I learn best. Upvote 0
Thanks Erel, I had a feeling that would be the case, I did try writing a library to return an NSComparisonResult, but it wouldn't cast to an Object. Presumably because it's part of an Enum. You were correct when you said that Objective C is more complex than Java. I have an awful lot of learning to do. Now you've implemented SortType in List, I'm sure I can achieve what I wanted using that. It was one of those, do it because you can experiments (or can't in this case). Experimenting is how I learn best.