#hackingwithswift
Explore tagged Tumblr posts
goodorbetterprogrammer · 3 years ago
Text
HackingWithSwift Day 42/43/44 - Project 10
Now get to be introduce to UICollectionViewController.
Overall more or less the same as objective-c. And the author introduce new thing, fatalError() - it will crash the app and print out the error message the developer code but it’s something needed as well if one just want to terminate the app if certain things didn’t go right and maybe no point for the user to continue it.
From the tutorial , maybe need to add 1 more thing is estimate size on at the storyboard there need to change to “None” instead of automatic or else the cell size setting won’t work
Then follow by UIImagePickerController, which needs UIImagePickerControllerDelegate and UINavigationControllerDelegate as well.
If we need to access the image later on, or want to store it in app private storage, what we can do is get a file path, and write it to the path. For example:
let paths = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask) let imageName = UUID().uuidString let imagePath = paths[0].appendingPathComponent(imageName) if let jpegData = image.jpegData(compressionQuality: 0.8) { try? jpegData.write(to: imagePath) }
Overall that’s all for this project.
1 note · View note
dailytech-info · 4 years ago
Photo
Tumblr media
@hacker_b0t follow us . . 🌐www.techyrick.com . . #hackercraft #quoteshacker #ikeahackers #biohacker #hackerone #häcker #hackermeme #hackingético #whitehathacker #hackingtool #hackerpschorr #vinniehackeredits #hackinglife #hackingtips #househacking #hackingwithswift #hackingthecity #hackingbooks #belajarhacking #hackingmemes #hackerschool #hackermemes #hackingshit #hackingfacts #hackersworld #happyhacking #hackerinstagram #ethicalhackers #hackerkiralama #hacker https://www.instagram.com/p/CQtdxwEgn4T/?utm_medium=tumblr
0 notes
egtion-blog · 6 years ago
Photo
Tumblr media
Day 9 of #100DaysOfSwift ••• #100daysofswift #iosdev #iosdeveloper #programming #developer #swiftlang #macos #ios #macbookpro #macbook #softwareengineer #softwaredeveloper #programmer #coder #coding #code #xcode #100daysofcode #hackingwithswift #lovecodes https://www.instagram.com/p/BylPgHfhQX_/?igshid=x5fw289hovhh
1 note · View note
smilingkenshi · 4 years ago
Text
2020: Year in Code
2020: Year in Code Git Repos: Dropbox 2020 Code Sketches: ├── AutolayoutBookWork ├── BluetoothLab ├── CollectionViewTest ├── CombineLab ├── DataSourceCellConfig ├── NSSecureCoding-Example-Objc ├── QR-Code-Generation-in-Swift.playground ├── SimpleAPIClient ├── Swift-Hackspace ├── SwiftUI\ -\ Apple\ Tutorials ├── SwiftUI-Lab ├── SwiftUIPlayPen ├── WWDC2020-Code-Sketches ├── mac-SwiftUI-Experiment └── month-bar-prototype Dropbox/Code Runner Scratchspace: ├── AdventOfCode2020 ├── FunctionalBoardGame ├── FunctionalBoardGame.swift ├── GenericsSpace ├── GenericsSpace.swift ├── NSArray-First-N-Elements.m ├── OpaqueReturnTypes.swift ├── Output-Bytes-of-Data-Type.swift ├── URL Construction.swift iMac Code Sketches: ├── dearPyGui │   ├── README.md │   └── hello.py ├── deno │   ├── README.md │   ├── app.ts │   └── oak-rest-api ├── iOS │   ├── EmojiHunter │   └── TimeScrubberControl ├── javascript-lang-fundamentals │   ├── Promises │   └── string-interpolation.js ├── nodejs │   ├── exploreFileSystem │   └── simpleServer ├── rails │   └── imageserver ├── sapper-stuff │   └── babylon ├── stimulusjs │   ├── README.md │   ├── stimulus-starter │   └── stimulus-without-build-system └── svelte-livestream └── svelte-project iMac Code for Twitch: ├── Apple-Swift-UI-Tutorial ├── BigList-Catalyst ├── HackingWithSwift-SwiftUI └── SwiftUI-PlayPen-Twitch iMac Git Repos: ├── Athena ├── Brainshots ├── OnboardingScreen ├── Project-Healthboost ├── StreakEngine-deleteme ├── ToastLab ├── Wisdom ├── dailylog ├── dailylog-streaks ├── data-sources-in-memory ├── daystream-website ├── dot-plan ├── focus-app ├── <name>.github.io ├── playsounds ├── streakkit ├── streakkit-client └── yapdatabaseexploration MBP Code Sketches: ├── deno-lab └── go-lab MBP Git Repos: ├── Athena ├── Code\ Sketches │   └── emoji-detection-in-ios ├── FileSystemAccess-MacApp ├── PlaySounds ├── UIKitFundamentals ├── Wisdom ├── combine-lab ├── dailylog ├── data-sources-in-memory ├── dot-plan ├── focus-app ├── kidbits.html ├── streakengine-swift ├── streakkit └── streaks-r-d Dashboards: ├── Dashboard ├── Dashboard-of-Outcomes └── Dashboard-of-Tasks bitbucket daily-dashboard.git Dashboard bitbucket outcomes-dashboard.git Dashboard-of-Outcomes bitbucket projects-dashboard.git Dashboard-of-Tasks ➜ Tasks l _Archived-Completed Bluetooth Learning Learn-Docker Learn-Python-Basics ➜ Tasks l _Archived-Abandoned Automate-the-Boring-Stuff Dashboard-Projects-ScreenCapture Learn-Category-Theory-With-Haskell Learn-Rust Releases: Dashboards, scripts, Daily Log, Focus app? Tech: Python, Ruby, Swift, ObjC, Deno, Javascript
0 notes
lewiskdavid90 · 8 years ago
Text
93% off #Swift 3 Mastery and iOS 10 – Novice to Pro – Build 17 Apps – $10
Learn how to work with Swift 3 and go from beginner to a pro developer by putting together 17 apps
Beginner Level,  – 19 hours,  143 lectures 
Average rating 4.6/5 (4.6 (31 ratings) Instead of using a simple lifetime average, Udemy calculates a course’s star rating by considering a number of different factors such as the number of ratings, the age of ratings, and the likelihood of fraudulent ratings.)
Course requirements:
You will need a Mac, and Xcode 8 which is a free download from the App Store, and simply a desire to transform your ideas into amazing apps
Course description:
This course will show you that building iOS apps with Swift 3 is fun and easy. Learn how to create 17 apps using Apple’s  new programming language Swift 3. Each project will build on the previous one, reinforcing what you have just learned, step by step, so theres no guesswork as to the process and what the code is doing. We go over each line and see what it’s doing, this is a great way to learn about the Cocoa touch classes, frameworks, methods, and everything iOS. The course makes use of callout graphics, diagrams, highlighting, and deep explanations to help guide you along the path of the code, so its easy to follow. When you understand how to put together one project, you can proceed to the next one with confidence, and implement your new skills as you go along. The author of these carefully crafted projects is the award winning Swift programmer, “Paul Hudson”. You can check out all of his work at hackingWithSwift,com. Paul and i teamed up to take many of his written tutorials and convert them into lecture format courses. He is among the top Swift programmers, and has received high praise from the creator of the Swift language, Chris Lattner, for his outstanding tutorials and method of teaching iOS, so you know your getting the best of the best here. This course also makes the perfect reference tool kit, to be used in conjunction with the Apple docs, so that you can go back and scrub through any of the lectures very quickly to pull out relevant code or instruction that you need, as there’s no wasted chatter here, it’s strictly on point with iOS.
Some of what you will be leaning:
Featuring apps built by the award winning Swift programmer – Paul Hudson – hackingwithswift,com We use Xcode 8.2.1 – The latest version The Swift 3 language – we go from variables to creating our own functions and more Learn Swift by use of diagrams / highlighting / graphics  Learning the ins and outs of Xcode 8  Working in storyboards and all it nuances  How to use with controls / Outlets and Actions  How to use logic for smooth control flow Using segues and passing data, in storyboards, and programmatically Master table and collection view controller Using delegates and protocols Work with the social framework – FB – Twitter etc. Learn how to refactor code The ins and outs of GCD SpriteKit and Games The new UserDefaults to persist data Adding audio / Animations Master strings in Swift 3 Using stackView The safari view controller class Using core image Learn the best debugging techniques Create an extension for your app
Working with the many swift classes available to us Autolayout easy and advanced – create constraints using VFL Learn how to work with JSON data in swift And a ton more… All videos are recorded in HD for maximum resolution and clarity
Swift is the new language of the future, and with this course you will get plenty of instruction on how to implement Swift code in unique ways, in an easy to understand step by step format. And before you know it you will have built many amazing apps that you can submit to the App Store, and place in the hands of thousands of people.
This course assumes you have no programming experience, so its perfect for the beginner. Its also a nice fit for the intermediate and experienced coder as the course covers advanced techniques as well.
By adding your own creativity and data, you will be transformed into an Apple Developer in a very short time.
Happy Coding
Tumblr media
Steve 
Full details Place your own amazing apps into the hands of thousands of people through the App Store Become completely proficient with Swift 3 and iOS app development This course is for anyone who has a burning desire to get their own creative ideas translated into apps, ready for the app store. We cover the complete Swift 3 language and then how to build apps in iOS – From beginner to advanced This is the perfect course if your coming from another language like Objective C or any oth
Reviews:
“I’ve taken all of Stephen Destefano’s courses at Udemy. What I love about him is his clear voice and explanation of each topic, from beginner to advance. He answers all his students questions with respect and clear responses knowing that we are beginners to his class. Highly, highly, highly recommend ALL his courses.” (Annabelle Ramos)
“This is a very informal course. He explains everything thoroughly and breaks it down. I’m coming from zero background in code so my learning is just like explaining 2+1 to a 4yr old. It takes time and effort. However Stephen has taken the time to reach back out every time I’ve had a question and will precisely break things down to a minute level. I’m learning a ton and finally understanding what I’m writing instead of just blindly typing.” (David Groomes)
“I almost took.5 off because I am not sure that this is for an abject beginning programmer to be. There are concepts being introduced that I am not sure a non-programmer would grasp so early, at least would have been for me. I am using this to fill in holes in my understanding of swift. I understand so much more now. This is an excellent course and I am happy that I am taking it. Peace, Myst.” (Donald Bradbury)
  About Instructor:
Stephen DeStefano
My name is Steve DeStefano, a long time iOS developer / instructor, and i’ve taken my passion for coding and building apps, and put together a series of comprehensive instructional courses, that will guide you through the process of creating apps in iOS. I stay current with the Swift language, and update it as it continues to evolve. I’ve worked with top programmers in the field, and offer a unique way of teaching IOS programming, which is to present the material in a concise and thoroughly explained manner, with the help of diagrams and highlighting, all to make it easy to follow the path of the code. If your think this might be too difficult, think again, and then come code along with me, and see how easy it is to learn swift and app creation. Go from a newbie to an Apple Dev in a short amount of time, and see your own unique creations on the App Store, and in the hands of thousands of people.
Instructor Other Courses:
iOS 10 Advanced Projects: Build Amazing Apps with Swift 3 Stephen DeStefano, iOS Developer / Swift Instructor (46) $10 $100 iOS 9 Swift Games and Techniques – Swift 2 Next level Coding The Swift 3 Cookbook of Code …………………………………………………………… Stephen DeStefano coupons Development course coupon Udemy Development course coupon Mobile Apps course coupon Udemy Mobile Apps course coupon Swift 3 Mastery and iOS 10 – Novice to Pro – Build 17 Apps Swift 3 Mastery and iOS 10 – Novice to Pro – Build 17 Apps course coupon Swift 3 Mastery and iOS 10 – Novice to Pro – Build 17 Apps coupon coupons
The post 93% off #Swift 3 Mastery and iOS 10 – Novice to Pro – Build 17 Apps – $10 appeared first on Udemy Cupón/ Udemy Coupon/.
from Udemy Cupón/ Udemy Coupon/ http://coursetag.com/udemy/coupon/93-off-swift-3-mastery-and-ios-10-novice-to-pro-build-17-apps-10/ from Course Tag https://coursetagcom.tumblr.com/post/155755939333
0 notes
goodorbetterprogrammer · 3 years ago
Text
HackingWithSwift Day 39/40 - Project 9
Golden rules - access remote resources must do it in background thread instead of main thread since that will freeze the UI which has to be run on the main thread. And GCD can fix that
And async() is the keyword, to switch from main thread to background thread, and vice versa. Although it says it’s First In First Out (FIFO) but then since one can open many thread run at the same time, so it’s kinda hard to say it’s FIFO all the time, unless one define one single operation queue and every task share the same thing.
Each thread priority is control by quality of service (QoS) , and there’s 4 QoS - .userInteractive - highest priority, almost dedicate all available resource to this thread - .userInitiated - it’s important still because you’ll need that task to complete to show something - .utility - something that need maybe a long time to complete but no immediate attention require - .background - run task that’s not important or something user doesn’t care much
User Interactive and User Initiated thread will eat the battery to boost performance, Utility try boost performance as possible but w/o killing the battery much, like 50:50 , while Background mode only cares about the battery part , 0 concern on performance and let it run forever.
There’s default mode as well, which is in between User Interactive and User Initiated
And no weak self needed in GCD closure as it get discarded after finish run
Example DispatchQueue.global(qos: .userInitiated).async
But after go background thread, we need to come back to main thread as well to update the ui after finished the background task.
Example DispatchQueue.main.async
So .global vs .main , between background and main thread.
But how do I know at certain point I’m on background thread or main thread?
Another way to use GCD
performSelector(inBackground:) and performSelector(onMainThread:)
1 note · View note
goodorbetterprogrammer · 3 years ago
Text
HackingWithSwift Day 36/37/38 - Project 8
This time is build UI with just code
So far this subject is review how to write constraint by code level.
Nothing much new besides Collection.enumerated, String.replacingOccurrences and didSet for the Property observe
So far not much surprise yet
0 notes
goodorbetterprogrammer · 3 years ago
Text
HackingWithSwift Day 33/34/35 - Project 7
Here introduce to UITabBarController
“Swift has built-in support for working with JSON using a protocol called Codable. When you say “my data conforms to Codable”, Swift will allow you to convert freely between that data and JSON using only a little code.”
Definition by the author, let’s see how powerful is this.
So it’s quite convenient to parse the json data into swift native support data type, instead of self declare and unwrap it layer by layer.
Only 1 thing is the window code to add a new tab, I think it’s time to update it using SceneDelegate since window is omitted from AppDelegate with the latest Xcode.
Seems like Codable usage is very wide, might need more research on this
0 notes
goodorbetterprogrammer · 4 years ago
Text
HackingWithSwift Day 30/31
https://www.hackingwithswift.com/read/6/2/advanced-auto-layout For this part, kinda hope the author can add in some visual aids instead of full text description on what to change as everyone may be using different screen size or different constraint to begin with
let label2 = UILabel() label2.translatesAutoresizingMaskIntoConstraints = false
translatesAutoresizingMaskIntoConstraints set to false to prevent iOS generate default auto layout constraints if we intend to do it manually
===========================
So time for Auto Layout Visual Format Language (VFL). I have try this before in ObjC, hope the syntax is not so complicated in swift
let viewsDictionary = ["label1": label1, "label2": label2, "label3": label3, "label4": label4, "label5": label5] view.addConstraints( NSLayoutConstraint.constraints(withVisualFormat: "H:|[label1]|", options: [], metrics: nil, views: viewsDictionary)) H = horizontal constraint | | = single pipe on both end means to go edge to edge in parent view (equivalent to leading space = 0,  trailing space = 0, or width = parent width)
view.addConstraints( NSLayoutConstraint.constraints(withVisualFormat: "V:|[label1]-[label2]-[label3]-[label4]-[label5]", options: [], metrics: nil, views: viewsDictionary))
V = vertical constraint | = single pipe at the start point means align from top - = dash in between, it’s vertical spacing , default = 10 points (equivalent to top spacing or bottom spacing, depends on the relationship between 2 views)
Now try update to this view.addConstraints( NSLayoutConstraint.constraints(withVisualFormat: "V:|[label1(==88)]-[label2(==88)]-[label3(==88)]-[label4(==88)]-[label5(==88)]-(>=10)-|", options: [], metrics: nil, views: viewsDictionary))
==88, 88 points for height (since it’s V) >=10, minimum bottom spacing 10 points (since it’s V)
Imagine if one need to change the height very frequent due to certain circumstances, human error may occur when wrong value input into it. So one can make use of metric, meaning aside the value to a variable and use that variable whenever needed, then can reduce human error
let metrics = ["labelHeight": 88]
view.addConstraints( NSLayoutConstraint.constraints(withVisualFormat: "V:|[label1(labelHeight)]-[label2(labelHeight)]-[label3(labelHeight)]-[label4(labelHeight)]-[label5(labelHeight)]->=10-|", options: [], metrics: metrics, views: viewsDictionary))
===========================
If turn to landscape, there will be constraint issue since the total height probably can’t fulfil 5 labels with 88 points height with the addition spacing in between. So we need to tell which constraint get higher priority
Constraint priority is a value between 1 and 1000. The higher the number, the higher the priority. 1000 = must follow. Since we know 88 points for height is impossible to be fulfilled in landscape mode, so can make that optional
view.addConstraints( NSLayoutConstraint.constraints(withVisualFormat: "V:|[label1(labelHeight@999)]-[label2(label1)]-[label3(label1)]-[label4(label1)]-[label5(label1)]->=10-|", options: [], metrics: metrics, views: viewsDictionary))
labelHeight@999 = set labelHeight with priority value 999 , so if it can’t fulfil the height set, auto layout can shrink it since it’s not 1000 label2(label1) = label2 copy label1 height (equivalent to label 2 equal height to label 1)
===========================
And then it’s Anchor time
Each view comes with widthAnchor, heightAnchor, topAnchor, bottomAnchor, leftAnchor, rightAnchor, leadingAnchor, trailingAnchor, centerXAnchor, and centerYAnchor.
If device language is those type from right to left, like Arabic, using leadingAnchor and trailingAnchor will flip the view the other way around. If want remain the same as leadingAnchor and trailingAnchor with language like English as device language, one need to use leftAnchor and rightAnchor instead.
var previous: UILabel?
for label in [label1, label2, label3, label4, label5] {    label.widthAnchor.constraint(equalTo: view.widthAnchor).isActive = true    label.heightAnchor.constraint(equalToConstant: 88).isActive = true
   if let previous = previous {        // we have a previous label – create a height constraint        label.topAnchor.constraint(equalTo: previous.bottomAnchor, constant: 10).isActive = true    }
   // set the previous label to be the current one, for the next loop iteration    previous = label }
By default the view will stick to the top if we don’t assign anything, so for the first label, we don’t need the topAnchor, only the following one onwards. BUT there’s one problem. To make sure the view look nice at iPhone X series or iPhone with notch, we need to ensure the top or bottom view is within the safe area zone
if let previous = previous {    // we have a previous label – create a height constraint    label.topAnchor.constraint(equalTo: previous.bottomAnchor, constant: 10).isActive = true } else {    // this is the first label    label.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor, constant: 0).isActive = true }
So we will need this to ensure it look nice.
0 notes
goodorbetterprogrammer · 4 years ago
Text
HackingWithSwift Day 27/28/29
Resuming….the closure nightmare
Weak vs strong vs unowned
class Singer {    func playSong() {        print("Shake it off!")    } }
func sing() -> () -> Void {    let taylor = Singer()
   let singing = {        taylor.playSong()        return    }
   return singing }
“taylor” inside the sing closure will never get destroy even after the function has returned, under “strong” reference.
===================== func sing() -> () -> Void {    let taylor = Singer()
   let singing = { [weak taylor] in        taylor?.playSong()        return    }
   return singing }
If change to “weak” then it’s possible to get destroy when it gets “nil”
“taylor” now become optional now, since it’s possible to be destroy at any time. But that also means “taylor” only exist inside sing()
======================
Alternative to weak will be “unowned”
func sing() -> () -> Void {    let taylor = Singer()
   let singing = { [unowned taylor] in        taylor.playSong()        return    }
   return singing }
Unowned is like implicit unwrap, meaning from the previous example, the “weak” taylor need to use “?” or “!” before calling playSong(), unowned is like weak + “!” together .
===================
Project Part
Array.randomElement = randomly return 1 object from the array
And learn about UITextChecker
0 notes
goodorbetterprogrammer · 4 years ago
Text
HackingWithSwift Day 24/25/26
Introduction to WKWebview
“The delegation solution is brilliant: we can tell WKWebView that we want to be informed when something interesting happens. In our code, we're setting the web view's navigationDelegate property to self, which means "when any web page navigation happens, please tell me – the current view controller.” Definition of delegation by the author, this will comes in handle when we create our own custom delegate after this.
class ViewController: UIViewController, WKNavigationDelegate
Parent class comes first, then only protocol next
@objc func openTapped() { let ac = UIAlertController(title: "Open page…", message: nil, preferredStyle: .actionSheet)        ac.addAction(UIAlertAction(title: "apple.com", style: .default, handler: openPage))        ac.addAction(UIAlertAction(title: "hackingwithswift.com", style: .default, handler: openPage))        ac.addAction(UIAlertAction(title: "Cancel", style: .cancel))        ac.popoverPresentationController?.barButtonItem = self.navigationItem.rightBarButtonItem        present(ac, animated: true) }
func openPage(action: UIAlertAction) { let url = URL(string: "https://" + action.title!)!        webView.load(URLRequest(url: url)) }
action.title is refer to the title set at the new instance of UIAlertAction
================== And the very first delegate we use under WKNavigationDelegate
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {        title = webView.title }
Whenever web view finished load a page, it will change the navigation title to be the same as web view title
==================
Now introduce UIToolbar and UIProgressView
var progressView: UIProgressView = UIProgressView(progressViewStyle: .default) progressView.sizeToFit() let progressButton = UIBarButtonItem(customView: progressView)
let spacer = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil) let refresh = UIBarButtonItem(barButtonSystemItem: .refresh, target: webView, action: #selector(webView.reload))
toolbarItems = [progressButton, spacer, refresh]
Wrap the progress button in UIBarButtonItem and add it to toolbarItems =============
Key-value observing (KVO)
To update the progressView we need to know the web view loading progress
webView.addObserver(self, forKeyPath: #keyPath(WKWebView.estimatedProgress), options: .new, context: nil)
Usually when do addObserver(), one need to take care of removeObserver() to ensure everything run fine
Then add the following method to get the value
override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {    if keyPath == "estimatedProgress" {        progressView.progress = Float(webView.estimatedProgress)    } }
Since we want to observe the key path of WKWebView.estimatedProgress, then inside the method, we check if the key path of the value is actually same as WKWebView.estimatedProgress. If it’s the same, we get the estimate progress and update the progressView progress.
The extra float casting is needed since webView.estimatedProgress is a Double, and progressView.progress only accept Float.
================= func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {    let url = navigationAction.request.url
   if let host = url?.host {        for website in websites {            if host.contains(website) {                decisionHandler(.allow)                return            }        }    }
   decisionHandler(.cancel) }
To ensure user can’t navigate to other page, need this delegate method to control the site, but need to read more on @escaping closure
===================
0 notes
goodorbetterprogrammer · 4 years ago
Text
HackingWithSwift Day 23
Review of project 1, project 2 and project 3
So far learn how to use UITableView, UIViewController, UIButton, UIImageView, UIBarButtonItem. And how to edit some of the view property using CALayer properties, such as  borderWidth, borderColor , and etc And learn about assistant editor view, to add IBOutlet and IBAction as well. And access resources using Bundle, and FileManager, like using the image assets, with the @2x , @3x concept
let items = try! fm.contentsOfDirectory(atPath: path)
Assume fm is FileManager object, swift will enforce you to wrap it in try catch when call contentsOfDirectory, that’s because the path might not exist or you type wrong name, but since our sample code won’t face that issue, we can just direct use try! instead of proper try catch.
When comes to UITableView, we also applied some of the protocol under UITableViewDelegate and UITableViewDataSource
0 notes
goodorbetterprogrammer · 4 years ago
Text
HackingWithSwift Day 22
Introduction to UIActivityViewController
let vc = UIActivityViewController(activityItems: [image], applicationActivities: []) vc.popoverPresentationController?.barButtonItem = navigationItem.rightBarButtonItem present(vc, animated: true)
You can add any item you want to the activityItemsArray, and popoverPresentationController code is needed for iPad , if the app only target iPhone then you can omit this part but best to provide it
There isn’t much to write about Project 3 , aside from the @objc tag for selector, which may need more research to know about it.
0 notes
goodorbetterprogrammer · 4 years ago
Text
HackingWithSwift Day 19/20/21
Project 2
var countries = [String]()
countries.append("estonia") countries.append("france") countries.append("germany")
countries += ["estonia", "france", "germany",]
Two ways to append array =======================
func askQuestion(action: UIAlertAction! = nil) { button1.setImage(UIImage(named: countries[0]), for: .normal)        button2.setImage(UIImage(named: countries[1]), for: .normal)        button3.setImage(UIImage(named: countries[2]), for: .normal) }
If assign a default value to a passing param for a function, when call the function, can just write askQuestion() without pass in anything. Looks confusing but better try to get use to it
============================
Just realized I can’t do ++ , but only += 1 when I try to do the challenge
For this project, not much note as per project 1 as well, since most of them I learned before when I use objective-c
0 notes
goodorbetterprogrammer · 4 years ago
Text
HackingWithSwift Day 16/17/18
Project 1
class ViewController: UIViewController {
   override func viewDidLoad() {        super.viewDidLoad()        // Do any additional setup after loading the view.
       let fm = FileManager.default        let path = Bundle.main.resourcePath!        let items = try! fm.contentsOfDirectory(atPath: path)
       for item in items {            if item.hasPrefix("nssl") {                // this is a picture to load!            }        }    } }
Data type start with “UI” = from uikit
Can go to Preference -> Text Editing -> Show Line Number
============== Way to add auto layout > Go to the Editor menu and choose > Resolve Auto Layout Issues > Reset To Suggested Constraints. > Press Shift+Alt+Cmd+= to accomplish the same thing. > Manually
Large title “One of Apple’s design guidelines is the use of large titles – the text that appears in the gray bar at the top of apps. The default style is small text, which is what we’ve had so far, but with a couple of lines of code we can adopt the new design.” - by the author
navigationController?.navigationBar.prefersLargeTitles = true
0 notes
goodorbetterprogrammer · 4 years ago
Text
HackingWithSwift Day 15
Properties - Which are the variables and constants Properties observer - didset , willset Computed Properties - variable with only get, no need assign value , get value on the fly Static Properties - make the properties belongs to the type instead of the instance Access Control - Public: this means everyone can read and write the property. - Internal: this means only your Swift code can read and write the property. If you ship your code as a framework for others to use, they won’t be able to read the property. - File Private: this means that only Swift code in the same file as the type can read and write the property. - Private: this is the most restrictive option, and means the property is available only inside methods that belong to the type, or its extensions.
// Declaring "A" class that has the two types of "private" and "fileprivate": class A {    private var aPrivate: String?    fileprivate var aFileprivate: String?
   func accessMySelf() {        // this works fine        self.aPrivate = ""        self.aFileprivate = ""    } }
// Declaring "B" for checking the abiltiy of accessing "A" class: class B {    func accessA() {        // create an instance of "A" class        let aObject = A()
       // Error! this is NOT accessable...        aObject.aPrivate = "I CANNOT set a value for it!"
       // this works fine        aObject.aFileprivate = "I CAN set a value for it!"    } }
https://docs.swift.org/swift-book/LanguageGuide/AccessControl.html Have to read more…….
============= TypeCasting
Typecasting “as?” allow you to check the data type is the one you want or not, else it will return nil and won’t execute the code inside the if statement
============= Closure …..might as well just read back the previous note for review.
0 notes