I get some errors when I try to convert 2 functions in Swift!
ObjC
@property (nonatomic, strong) NSMutableDictionary *textureCache;
- (instancetype)init {
if (self = [super init])
{
self.textureCache = [NSMutableDictionary dictionary];
}
return self;
}
- (SKTexture *)textureNamed:(NSString *)textureName {
return _textureCache[textureName];
}
Swift
var textureCache: NSMutableDictionary?
public func init() -> Self {
return textureCache = NSMutableDictionary()
}
public func textureNamed(textureName: String!) -> SKTexture! {
return textureCache(textureName)
}
In the "init" function :
- Expected identifier in function declaration -> (public func init -> Self)
- Cannot assign a value of type 'NSMutableDictionary' to a value of type 'NSMutableDictionary?' -> (return textureCache = NSMutableDictionary())
And for the "textureNamed" function :
- Cannot invoke 'textureCache' with an argument list of type '(String!)' -> (return textureCache(textureName))
If someone could help me, it would be awesome.