Post

Replies

Boosts

Views

Activity

Reply to Codding
👋, I would say just start. Really, it’s that simple but I understand your asking where to begin and with what. You need to learn the syntax so I’d advise going to Codecademy and start learning the syntax with them because it’s guided and easier to learn. once you’ve done that, head into Xcode (CA will guide how to do that) and start building little projects using a one framework become good at it and then move to the next. now if your a straight from a book learner then use the into to app development book in the Apple book store and read it inside out. but I think it comes down to you— why do you want to do coding? Swift is a great first language because of the ease of use but if your intention is to just make money then you need to workout why you want to do it not what the result is of what your doing. other than that, welcome to the coding club! 🎉 best, Imran
Jul ’21
Reply to How do I setup Music Kit authorisation?
Hi, Thanks for your reply. So I tried this and nothing happens. No crashes nothing. It does perform anything. As per the document, I have added the Plist permission with a text to say why I need permission. This plist thing is supposed to automatically display a alert to accept or deny permission when the app launches as per the doc and this function is supposed to request user permission as a button like Connect Apple Music -> User permission granted and so forth... Except the problem is the original code from Apple dev tutorial is for SwiftUI. I need Uikit that's where I am struggling. Here is the code from the tutorial: @State var isAuthorizedForMusicKit = false func requestMusicAuthorization() { detach { let authorizationStatus = await MusicAuthorization.request() if authorizationStatus == .authorized { isAuthorizedForMusicKit = true } else { // User denied permission. } } } here is my version of it with your help with the button:  func configureRequestButton() {         let button = UIButton()         button.setTitle("Test", for: .normal)         button.setTitleColor(.systemBlue,for: .normal)         button.addTarget(self,                          action: #selector(requestMusicAuthorization),                                                    for: .touchUpInside)         StackView.addArrangedSubview(button)     }               @objc func requestMusicAuthorization() {       Task {        do {         let authorizationStatus = await MusicAuthorization.request()         if authorizationStatus == .authorized {          isAuthorizedForMusicKit = true         } else {          // User denied permission.         }        } catch {         print(error)        }       }      } I hope this helps with What I am trying to achieve here. It should only show when the user launches the app for the first time. After we get persimision it doesn't need to show again until they deny permission. Best, Imran
Jul ’22
Reply to Converting a String to a Double
Hey, Check this: let number = 100 let string = "100"     //Prints number as a string print(String(number))     //prints Number as String print(Int(string))     //Prints Number as a Double print(Double(number)) let converted = Int(string) ?? 100     // without the ?? optional unwrapping you will get an optional output. Givt it a default value in case nothing comes back.     //prints converted number  print(converted) Hope this helps. Best, Imran
Sep ’22
Reply to Where am I going wrong?
Here is my updated View Controller: Here is my updated View Controller sorta or trying to do what you mentioned: import UIKit class ViewController: UIViewController {          enum Section {         case main     }          var collectionView: UICollectionView!     var dataSource: UICollectionViewDiffableDataSource<Section,Product>?     var products: [Product] = []               override func viewDidLoad() {         super.viewDidLoad()         // Do any additional setup after loading the view.                  navigationItem.title = "Products"         view.backgroundColor = .white                  //Uncomment when needed         configureHierarchy()         configureDataSource()                  collectionView.register(ListCell.self, forCellWithReuseIdentifier: "ListCell")              }          func configure<T: SelfConfiguringCell>(with product: Product, for indexPath: IndexPath) -> T {         guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "ListCell", for: indexPath) as? T else {             fatalError("Unable to dequeue Cell")         }         cell.configure(with: product)         return cell     }          func loadProducts() async {         self.products = await APIService().listProducts()     }      } extension ViewController {     private func createLayout() -> UICollectionViewLayout {         let config = UICollectionLayoutListConfiguration(appearance: .insetGrouped)         return UICollectionViewCompositionalLayout.list(using: config)     } } extension ViewController {     private func configureHierarchy() {         collectionView = UICollectionView(frame: view.bounds, collectionViewLayout: createLayout())         collectionView.autoresizingMask = [.flexibleWidth, .flexibleHeight]         view.addSubview(collectionView)         collectionView.delegate = self     }                    private func configureDataSource() {                  let cellRegistration = UICollectionView.CellRegistration<UICollectionViewListCell, Product> { (cell, indexPath, product) in             var content = cell.defaultContentConfiguration()             content.text = "\(product.name)"             cell.contentConfiguration = content         }                  dataSource = UICollectionViewDiffableDataSource<Section, Product>(collectionView: collectionView) {             (collectionView: UICollectionView, indexPath: IndexPath, identifier: Product) -> UICollectionViewCell? in             return collectionView.dequeueConfiguredReusableCell(using: cellRegistration, for: indexPath, item: identifier)         }                  //inital data                 var snapshot = NSDiffableDataSourceSnapshot<Section, Product>()         snapshot.appendSections([.main])         //Problem loading this information         snapshot.appendItems([], toSection: .main)         dataSource?.apply(snapshot, animatingDifferences: false)              }      } extension ViewController: UICollectionViewDelegate {     func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {         collectionView.deselectItem(at: indexPath, animated: true)     } }
Sep ’22
Reply to How do I arrange the stack view to show the profile image next to the username?
I hope this helps-- The whole code for the table cell I am making: import UIKit class PostsTableViewCell: UITableViewCell {     static let reuseIdentifier: String =  "PostsTableViewCell"          private let profileImageView: UIImageView = {         let imageView = UIImageView()         imageView.translatesAutoresizingMaskIntoConstraints = false         imageView.contentMode = .scaleAspectFill                 imageView.layer.masksToBounds = true         imageView.layer.cornerRadius = 10         imageView.clipsToBounds = true                  let config = UIImage.SymbolConfiguration(pointSize: 35)         imageView.image = UIImage(systemName: "person.crop.circle.fill", withConfiguration: config)                  //imageView.backgroundColor = .white         return imageView     }()          private let profileNameLabel: UILabel = {         let label = UILabel()                  label.text =  "Testing User"         label.font = .systemFont(ofSize: 16, weight: .bold)         label.translatesAutoresizingMaskIntoConstraints = false         return label     }()               private let userHandel: UILabel = {         let label =  UILabel()         label.text =  "@Test"         label.font = .systemFont(ofSize: 12, weight: .light)         label.textColor = .systemBlue         label.translatesAutoresizingMaskIntoConstraints =  false                  return label     }()               private let postTextLabel: UILabel = {         let label = UILabel()         label.text = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."         label.numberOfLines = 0         label.font = .systemFont(ofSize: 14, weight: .regular)         return label              }()               override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {         super.init(style: style, reuseIdentifier: reuseIdentifier)         contentView.addSubview(profileImageView)         contentView.addSubview(profileNameLabel)         contentView.addSubview(userHandel)                                    profileImageView.setContentHuggingPriority(.defaultHigh, for: .horizontal)                                                               let innerPostStackView = UIStackView(arrangedSubviews: [profileNameLabel, userHandel, postTextLabel])         innerPostStackView.axis = .vertical                       let postStackView = UIStackView(arrangedSubviews: [profileImageView, innerPostStackView])         postStackView.translatesAutoresizingMaskIntoConstraints =  false         postStackView.alignment =  .center         postStackView.spacing = 10         contentView.addSubview(postStackView)                           NSLayoutConstraint.activate([             postStackView.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: 10),             postStackView.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: -15),             postStackView.topAnchor.constraint(equalTo: contentView.topAnchor, constant: 10),             postTextLabel.bottomAnchor.constraint(equalTo: contentView.bottomAnchor, constant: -15)                                                      ])                       }               required init(coder: NSCoder) {         fatalError("Post failed to load")     } } I tried to the paste and match thing But I Don't how that works. I just used the code block after pasting it. Best, Imran
Nov ’22