ios - Set an uilabel on callback function -
I set the text of UIBLL on the callback of cfsocket, but this does not work. Error: "Use of undisclosed identifier label" '' But this set-test works in other functions, why not in this one?
Callback function:
Fixed zero return data (CFSocketRef s, CFSocketCallBackType type, CFDataRef address, const zero * data, zero * info) {UInt8 * buff; NSLog (@ "% ld", CFDataGetLength (data)); CFDataGetBytes (Data, CFRangeMake (0, CFDataGetLength (data)), Fondness; NSLog (@ "% s", Fond); [Label set text: @ "Tooto"];} Function where set-test function:
- (IBAction) deconn: (id) sender {if (conn_ok & amp; socket & amp; sock_addr) {CFSocketInvalidate (socket); [ Label set text: @ "disconnected"]; Conn_ok = false; [Sock_addr release];}}
Okay, I did this in my work:
socketViewController * toto = (id) information; [Toto.label setText: @ "Received msg"]; But this does not work, let me EXEC_BAD_ACCESS get And I have it logged in:
Shared Library Applicable Load Rules All Warnings: Disable to restore previously selected frames (GDB) < P> I think this is a memory access problem, I have not changed anything at the end of the toto = nil; function.
received data is a function, not the method you are trying to use private object of an object Are there. If you had used the accessories ( self.label ) then it would be more clear. Use the accessories. You can use the info pointer to pass the callback to manually so you can access the label. To configure information pointer, you must pass a reference when you create a socket: CFSocketContext context = {0 , Self, NULL, NULL, NULL}; Now in your CFSocketCreate ... call, you can enter & amp; Reference will pass. Instead of applying its own CFSocket , I usually recommend it provides a very handy interface.
Comments
Post a Comment