मैं एक नया स्विफ्ट ऐप बनाने पर काम कर रहा हूं जो मोटे तौर पर पुराने ओब्जे-सी ऐप पर आधारित है। मैं वर्तमान में प्रतिनिधियों पर काम कर रहा हूँफ़ाइल का दायरा? स्विफ्ट प्रतिनिधि और प्रोटोकॉल
यहाँ क्या मेरी Obj सी कोड
@interface MyAppViewController : CustomViewController
@property (nonatomic, weak) id<MyAppViewControllerDelegate> delegate;
@end
@protocol MyAppViewControllerDelegate <NSObject>
- (void)myAppViewController:(MyAppViewController *)controller loggedInStudent: (MYStudent *)student;
- (void)myAppViewControllerWantsSignUp:(MyAppViewController *)controller;
@end
ज फ़ाइल में की तरह दिखाई देता स्विफ्ट मैंने किया था में है:
class MyAppViewController: CustomViewController {
var delegate: MyAppViewControllerDelegate?
protocol MyAppViewControllerDelegate{
func myAppViewController(controller: MyAppViewController, loggedInStudent: MYStudent)
func myAppViewControllerWantsSignUp(controller: MyAppViewController)
मेरे द्वारा की गई इस पर बहुत सी पढ़ाई और अध्ययन, इसलिए मैंने सोचा कि मैं इसे मूल रूप से सही कर रहा था (हालांकि पूरी तरह से नया करने के लिए नया ... इसलिए)
मुझे यह त्रुटि मिल रही है, हालांकि Declaration is only valid in file scope
"पर मुझे लगता है कि इसे कक्षा में घोषित करने के साथ कुछ करने के लिए किया गया था, इसलिए मैंने इसे बाहर ले जाया, केवल अब कक्षा के भीतर मेरा कोड घोषित प्रतिनिधि चर को पहचानता नहीं है ..
कोई विचार?