๐Ÿ”ฐAccess Control

ๅญ˜ๅ–ๆŽงๅˆถๆœ€้‡่ฆ็š„ๅ…ฉๅ€‹ๅˆ†้‡Ž็‚บ module ๅ’Œ source file๏ผš

  • module๏ผšไธ€ๅ€‹ bundle ID ไธ‹็š„ app ๆˆ–ไธ€ๅ€‹ frameworkใ€‚

  • source file๏ผšๅฐฑๆ˜ฏๆฏไธ€ๅ€‹ .swift ๆช”ๆกˆใ€‚

ๅˆ† 5 ๅ€‹ๅฑค็ดš๏ผŒๆœ€้ซ˜ๅˆฐๆœ€ไฝŽไพๆฌก็‚บ๏ผš

  • open / public / internal / file-private / private

fileprivate

The only reason you would use fileprivate is when you want to access your code within the same file from different classes or structs. ๐Ÿ‘‰ SwfitLee

// fileprivate setter
fileprivate(set) var a = 1

private

extensions have to be defined within the same file, private declarations are not visible outside the file.

Last updated