Author: NhatHM
-
Fresher Training—iOS Swift Day 3
Today topic: Access Control & Code Organization Custom Operators, Subscripts & Keypaths Pattern Matching Error Handling Thao khảo: Swift—Advanced control flow Exercises: Exercise 01: SINGLETON A singleton is a design pattern that restricts the instantiation of a class to one object. Use access modifiers to create a singleton class Logger. This Logger should: Provide shared,…
-
Swift—Advanced control flow
Bài viết này giới thiếu cái khái niệm và các dùng về control flow trong Swift: For loop Countable ranges countable closed range: 0…5 countable half-open range: let halfOpenRange = 0..<5 For in với where condition Swift hỗ trợ for in where để lọc ra các điều kiện phù hợp trong tập cho trước: var…
-
Fresher Training—iOS Swift Day 2
Today topic: Properties Methods Advanced Classes Enumerations Protocols Generics Exercises: Exercise 01: PROPERTY Show me an example about a struct have property is another struct What is type property, example by source code 1 and 1 point Exercise 02: Methods Define struct Coordinate with property have latitude and longitude. Write a method to get/set for…
-
Fresher Training—iOS Swift Day 1
Today topic: Expressions, Variables & Constants Types & Operations Control Flow Functions Optionals Arrays, Dictionaries & Sets Collection Iteration with Closures Strings Structures Classes Exerices: Exercise 01: Expressions, Variables & Constants Declare four constants named x1, y1, x2 and y2 of type Double. These constants represent the 2-dimensional coordinates of two points. Calculate the distance…
-
Swift—Closure
Khi mới làm quen với Swift, đôi khi ta gặp phải những đoạn code như dưới: Tuy nhiên ta không hiểu chúng là gì, và dùng như nào. Trong Swift, những đoạn code kiểu như trên được gọi là Closure, bài Note này sẽ đi sâu vào bới móc xem Closure là gì ;)) Trong Swift…
-
Missing pieces for developers using macOS
Homebrew (The missing package manager for macOS) Homebrew là package manager rất có ích cho macOS, nó giúp bạn cài đặt các thư viện, ngôn ngữ, framework… rất nhanh và dễ dàng. Ưu điểm của Homebrew đó là bạn chỉ cần gõ câu lệnh để cài đặt package mà được Homebrew support, sau đó nó…
-
Swift —Giới thiệu sơ lược
Swift là gì?Swift là ngôn ngữ lập trình được phát triển bởi Apple, do Chris Lattner làm trưởng nhóm thiết kế. Lần đầu tiên được giới thiệu công khai là vào WWDC năm 2014 của Apple. Năm 2015, Swift chính thức trở thành open source và từ đó luôn phát triển mạnh mẽ với những đóng góp…
-
Swift — Optionals, Guard and Nil Coalescing
Guard Guard cũng gần giống như “if let” (optionals binding), nó cũng được sử dụng để xử lý các object dạng Optionals, cũng check các điều kiện khác “nil” thì cho phép thực hiện các logic tiếp theo… Nhưng Guard còn được gọi với tên gọi khác là “Early Exit”, vậy Guard khác “if let”…
-
Swift — Đôi nét về Optionals
Swift đã giới thiệu một khái niệm mới là Optionals. Vậy Optionals là gì? Optional là một khái niệm đặc biệt trong Swift dùng để xử lý việc thiếu giá trị (absence of value — của variable, const, object…) Thiếu giá trị là gì? Trong Objective-C, khi muốn thể hiện biến hay object nào đó không có…