Sto provando a convertire il mio Objective-C in Swift - un po 'confuso sull'errore qui e su come gestirlo. Ho letto la documentazione ma sono ancora confusa: è stata generata da un convertitore. Qualcuno ha qualche idea?Identificatore previsto nella dichiarazione di funzione - Obiettivo da C a Swift
Objective-C
- (id) init
{
self = [super init];
if (!self)
return nil;
self.cmRequestsQuery = [[NSMutableArray alloc] initWithCapacity:5];
self.cmQueryIsRuning = NO;
self.requestCounter = 0;
self.serverOfflineOrBadResponse = NO;
self.userWasLoggedIn = NO;
self.needToSendPushNotiToken = NO;
self.noInternetConection = NO;
self.needToUpdateToken = NO;
[[reqOperationManager sharedManager] setDelegate:self];
return self;
}
Swift
func init() -> AnyObject {
self = super()
if !self {
return nil
}
self.cmRequestsQuery = NSMutableArray(capacity: 5)
self.cmQueryIsRuning = false
self.requestCounter = 0
self.serverOfflineOrBadResponse = false
self.userWasLoggedIn = false
self.needToSendPushNotiToken = false
self.noInternetConection = false
self.needToUpdateToken = false
reqOperationManager.sharedManager().setDelegate(self)
return self
}
provare: super.init(); – eliasRuizHz
Che si è preso cura di un problema, si lamenta ancora a 'func init() -> AnyObject {' with "Identificatore previsto nella dichiarazione di funzione.Rimozione della parte" func "quindi porta l'errore" Le dichiarazioni consecutive su una riga devono essere separate da ';'. Credo che sia dall'aspetto AnyObject. – user2836292
Vedere [Questo collegamento] (http://stackoverflow.com/questions/24302288/how-to-write-init-method-in-swift) – eliasRuizHz