Use OC Swift Intercept The last file name in the path
How to intercept the last file name in the path below Appdelegate.swift
/users/xxx/desktop /swift/swift02/code/02 - Custom Log/weibo/weibo/appdelegate.swift
Use OC How to Intercept
-(NSString *) Substringfromwith: (NSString *) str
{
Nsinteger local = 0;
while ([str rangeofstring:@ "/"].location! = Nsnotfound)
{
local = [str rangeofstring:@ "/"].location + 1;
str = [STR substringfromindex:local];
}
return str;
}
In fact, this method is better NSString classification method
Use Swift and how to intercept
What T means: what is being introduced into the world
Func njlog<t> (message:t, file:nsstring = __file__, method:string = __function__, Line:int = __LINE__)
{
#if DEBUG
Print ("\ (file)")
var file2:nsstring = File
var local:int = 0
while (File2.rangeofstring ("/")). Location! = Nsnotfound
{
Local = (file2.rangeofstring ("/")). Location + 1;
File2 = File2.substringfromindex (local)
}
Print ("\ (File2) \ (method) [\ (line)]: \ (message)")
#endif
}
Use OC Swift to intercept the last file name in the path