Use OC Swift to intercept the last file name in the path

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.