![]() In essence, that's the only alternative that any current Swift developer has, to distributing multiple ABI-versioned binary frameworks. If you want to pursue a 2-framework solution, one choice would be to distribute the Swift "wrapper" framework (which would be very tiny) in source form. The fact that you're dealing with a pure C pointer (not Obj-C) translates the ugliness into Swift, too. (BOOL)getIsDone:(BOOL*)isDone error:(NSError**)errorĪnd that pattern means you're dealing with a "BOOL*", not a "BOOL". The deeper problem is that the Obj-C pattern for this is already ugly: Is there a way to tell the clang compiler to convert it to something like this? Pleeease? Or maybe func getIsDone(isDone: inout Bool) throws What I would prefer is something like: func isDone() throws -> Bool boolValue to actually use it.Īs you can see, both variants are really bad. Which is really unclear for the user why this is an NSNumber and he has to use. Now in Swift, the first solution would map to: func getIsDone(isDone: UnsafeMutablePointer) throwsĪnd the second one to: func isDone() throws -> NSNumber But now the framework needs to nicely map to a swift funtion. In Objective-C, we so far used the first solution for this. Or: Return an NSNumber that is nil if there is an error or contains a BOOL if not. Send the return value as a pointer and fill it: -(BOOL)getIsDone:(BOOL*)isDone error:(NSError**)error So the usual ways I have found so far to do this are these: The return value tells the user if there was an error, but doesn't return any value. Now (as you, who will hopefully answer this question, will know) if this should return an error at the same time, I can't do it like this, as in: - (BOOL)isDone:(NSError**)error If I just needed a method that returns a BOOL, that would look like this: - (BOOL)isDone ![]() Is there a nice and for the user understandable way to do that? Boy was I wrong.We have the (usual?) problem that we need a method that returns a BOOL and can throw an error, inside a Framework that can be used from Objective-C and from Swift. I also thought I had the logic down to have the user's direction based on the current floor and destination floor. Now my code takes in the 10 user requests from T1.txt file and generates a request node that has the attributes Timestamp(the floor in which it was requested at), and the Current floor(the originating floor of the user making the reques), and finally the Destination floor(user's desired destination). Void setNode(reqNode nizzode, int priority) Int size = waiting_queue.size() //set to wait queue's size UPDATE: PRIORITY TO BE CALCULATED BY REFERENCE POINT (DETERMINED BY DIRECTION) IN DRIVER BY CALL TO REQNODE METHOD Service_leteMin(*temp) // min item is serviced pop from heapįinished.push(*temp) // place serviced node to finished bank While( service_queue.findMin().destination = get_elevator_floor() )//check top node to see if it is done current floor is destination Increment_elevator_floor() // increments/decrements elevator floor by one. ![]() reqNode *temp = new reqNode īinaryHeap( ): Array( 11 ), theSize( 0 )// else set direction to top node's direction When I was trying to figure out a way to assign the direction of the user's making requests for the elevator to service it(the request the user makes). I have no clue where my logic went wrong. Instead I am getting as output: Node 0 : 1 3 7 205 I am currently trying to output the direction using Boolean values.ġ signifies the elevator going up. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |