كائن يلقي في مكالمة مع industselectoronmainthead ios
-
14-11-2019 - |
سؤال
إذا كنت تستخدم giveacodicetagpre.
في الطريقة - (الفراغ) UploadDEdend: (ID) المرسل
أي كائن مرسل؟في مكالمة فو هي فئة مخصصة؟كيف يمكنني تحويل هذا المرسل في كائني؟
أحاول الإدلاء ولكن لدي giveacodicetagpre.
في الإخطارات، يمكنني استخدام مصبوغ من المرسل إلى NSNotification وإخطار خاصية الكائنات، ولكن بالنسبة إلى NSThread لم أجدها.
شكرا.
المحلول
You can think of:
[self performSelectorOnMainThread:@selector(uploadDidEnd:)
withObject:foo
waitUntilDone:YES]
as sort of the same as:
[self uploadDidEnd:foo];
Are you sure that's what you're trying to do?
If so: inside your uploadDidEnd:
implementation, you can cast foo to whatever object type it really is like so:
- (void)uploadDidEnd:(id)sender
{
FooClass *foo = (FooClass *)sender;
[foo doSomething]; // or whatever
}
نصائح أخرى
The argument declared a
sender
is the only parameter passed to your method. performSelectorOnMainThread:withObject:waitUntilDone: passes its argument afterwithObject
to the selector to be performed, so yes, herefoo
will be passed to uploadDidEnd:Casting is not a solution. Objective-C is a dynamic language, so even if casting eliminates compiler warnings, the actual implementation of the object wouldn't change, so it naturally would not repond to messages.