Helper | ||
Images | ||
.swiftlint.yml | ||
README.md | ||
swift.jpeg |
Useful Swift Things
Content
- Coding convention
- Design Pattern
- Code Structuring
- UIDesign
- Helper
- API
- JSON
- Third Party Library
- Useful Stuff
Coding convention
set of guidelines for a specific programming language that recommend programming style
Swift Style Guide
Swift Lint
The way of force you to adapt coding convention
otherwise project build will FAILED
- Swift Lint apply for all project👍
if which swiftlint >/dev/null; then
swiftlint
else
echo "error: SwiftLint not installed, download from https://github.com/realm/SwiftLint"
exit 1
fi
put .yml file into root folder and apply following code in Build Phases
You can modify(delete) SwiftLint Option with opening .yml file
Shift + Command + . will show the hidden file
Design Pattern
Design pattern is
Check this website for design pattern in Swift
Delegate Pattern
weak var delegate: SomeProtocol?
Singleton Pattern
class SingletonPattern {
static let manager = SingletonPattern()
private init() {}
}
Observer Pattern
Code Structuring
MVC
MVVM
MVC vs MVVM
M -> Model – Which holds the application data
V –> View – It displays the data that is stored in model. These are visual elements through which a user interacts. These are subclasses of UIView
VM –> View Model – Transform model information/data and it interacts with controller or view to display those informations.
C –> Controller class – It will be there but the responsibility of view business logic has been removed and give to view model
Viper
UIDesign
HIG(Human Interface Guidelines)
iOS icon
- icon8 you can download icons for your APP
UIdesign inspiration
Helper
You can check the file in the follow link
Usage
import MesaageUI first
import MessageUI
Then use it
lazy var manager = ConversationManager(presentingController: self, mailDelegate: self, messageDelegate: self )
func sendEmail() -> MFMailComposeViewController {
manager.sendEmail(feedback: MailFeedback(recipients: ["abcd@example.com"], subject: "Sample", body: "Write body"))
}
func sendMessage() -> MFMessageComposeViewController {
manager.sendMessage(feedback: MessageFeedBack(recipients: ["1111111111"], body: "Type here"))
}
func call() {
manager.makeCall(number: "1111111111")
}
API
Various API Site
JSON
JSON is a language-independent data format
Which is relative with KEY - VALUE pair
{
"main": [
{
"title": "example1",
"body": "body1"
},
{
"title": "example2",
"body: "body2"
},
]
}
JSON parser extension for Chrome
This extension makes JSON more structable JSON parser pro FREE 👍
JSON Decoding
JSONSerialization
Third Party Library
This github contains all the popular libraries in Swift👍
Useful Stuff
Show Preview in UIKit(Build UI with Code Base)
import SwiftUI
struct ViewControllerRepresentable: UIViewControllerRepresentable {
typealias UIViewControllerType = ViewController
func makeUIViewController(context: Context) -> ViewController {
return ViewController()
}
func updateUIViewController(_ uiViewController: ViewController, context: Context) {
}
}
@available(iOS 13.0.0, *)
struct ViewPreview: PreviewProvider {
static var previews: some View {
ViewControllerRepresentable()
}
}