Close Menu
  • Home
  • AI
  • Big Data
  • Cloud Computing
  • iOS Development
  • IoT
  • IT/ Cybersecurity
  • Tech
    • Nanotechnology
    • Green Technology
    • Apple
    • Software Development
    • Software Engineering

Subscribe to Updates

Get the latest technology news from Bigteetechhub about IT, Cybersecurity and Big Data.

    What's Hot

    ios – SwiftUI: Zoom-navigation-transitions not working in tabViewBottomAccessory with a view model

    December 9, 2025

    Computational Approach Stabilizes Metallene for Nanotech

    December 9, 2025

    Sophos Firewall v22 is now available – Sophos News

    December 9, 2025
    Facebook X (Twitter) Instagram
    Facebook X (Twitter) Instagram
    Big Tee Tech Hub
    • Home
    • AI
    • Big Data
    • Cloud Computing
    • iOS Development
    • IoT
    • IT/ Cybersecurity
    • Tech
      • Nanotechnology
      • Green Technology
      • Apple
      • Software Development
      • Software Engineering
    Big Tee Tech Hub
    Home»iOS Development»swift – no products or categories on the ViewController in TableView in iOS app with api woocommerce
    iOS Development

    swift – no products or categories on the ViewController in TableView in iOS app with api woocommerce

    big tee tech hubBy big tee tech hubNovember 25, 2025022 Mins Read
    Share Facebook Twitter Pinterest Copy Link LinkedIn Tumblr Email Telegram WhatsApp
    Follow Us
    Google News Flipboard
    swift – no products or categories on the ViewController in TableView in iOS app with api woocommerce
    Share
    Facebook Twitter LinkedIn Pinterest Email Copy Link


    I begin to create online shop iOS app with connection to site on Woocommerce. I want to insert in TableView products from Woocommerce via API.

    Now then I Build the app, simulator launch only white empty screen. In the final result I want to launch iOS app with connection to site on Woocommerce, but I create it step by step, and first step, now, I want to make screen with product or categories from this shop. Why does my iOS app show a blank screen when I try to display WooCommerce products in a TableView via the API?

    Product.swift

    struct Product: Codable {
        let id: Int
        let name: String
        let price: String
        let regular_price: String?
        let sale_price: String?
        let description: String?
        let short_description: String?
        let images: [ProductImage]?
    }
    
    struct ProductImage: Codable {
        let src: String
    }
    

    ViewController.swift

    ViewController.swift
    
    import UIKit
    
    class ViewController: UIViewController {
        @IBOutlet weak var tableView: UITableView!
        private let api = WooCommerceAPI()
        private var products: [Product] = []
        
        override func viewDidLoad() {
            super.viewDidLoad()
            fetchProducts()
        }
        
        func fetchProducts() {
            let urlString = "
            guard let url = URL(string: urlString) else { return }
            
            URLSession.shared.dataTask(with: url) { data, response, error in
                // 1. Проверка ошибок
                if let error = error {
                    print("Ошибка сети: \(error)")
                    return
                }
                
                // 2. Обработка данных
                guard let data = data else { return }
                do {
                    // Здесь декодируйте JSON (например, в массив продуктов)
                    print("Данные получены: \(data)")
                } catch {
                    print("Ошибка декодирования: \(error)")
                }
            }.resume()
        }
    }
    

    WoocommerceAPI.swift

    import Foundation
    
    
    class WooCommerceAPI {
        private let baseURL = "
        private let consumerKey = "ck_1255d3fa39b33e661fc91e9fe17dd16fb4367e5"
        private let consumerSecret = "cs_707ff6ee2e25206a2858c5f288f57dd18acf8358"
        
        func fetchProducts(completion: @escaping ([Product]?) -> Void) {
            let endpoint = "\(baseURL)/products"
            let urlString = "\(endpoint)?consumer_key=\(consumerKey)&consumer_secret=\(consumerSecret)"
            
            guard let url = URL(string: urlString) else {
                completion(nil)
                return
            }
            
            URLSession.shared.dataTask(with: url) { data, response, error in
                if let error = error {
                    print("Ошибка: \(error.localizedDescription)")
                    completion(nil)
                    return
                }
                
                guard let data = data else {
                    completion(nil)
                    return
                }
                
                do {
                    let products = try JSONDecoder().decode([Product].self, from: data)
                    completion(products)
                } catch {
                    print("Ошибка декодирования: \(error.localizedDescription)")
                    completion(nil)
                }
            }.resume()
        }
    }
    



    Source link

    API app categories iOS Products Swift TableView ViewController woocommerce
    Follow on Google News Follow on Flipboard
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email Copy Link
    tonirufai
    big tee tech hub
    • Website

    Related Posts

    ios – SwiftUI: Zoom-navigation-transitions not working in tabViewBottomAccessory with a view model

    December 9, 2025

    android – How to Optimize a Flutter application

    December 8, 2025

    How to Add Many iOS 26 Icon Themes with Icon Composer in SwiftUI?

    December 7, 2025
    Add A Comment
    Leave A Reply Cancel Reply

    Editors Picks

    ios – SwiftUI: Zoom-navigation-transitions not working in tabViewBottomAccessory with a view model

    December 9, 2025

    Computational Approach Stabilizes Metallene for Nanotech

    December 9, 2025

    Sophos Firewall v22 is now available – Sophos News

    December 9, 2025

    The Real Magic of the Season: AI-Powered Workplaces

    December 9, 2025
    About Us
    About Us

    Welcome To big tee tech hub. Big tee tech hub is a Professional seo tools Platform. Here we will provide you only interesting content, which you will like very much. We’re dedicated to providing you the best of seo tools, with a focus on dependability and tools. We’re working to turn our passion for seo tools into a booming online website. We hope you enjoy our seo tools as much as we enjoy offering them to you.

    Don't Miss!

    ios – SwiftUI: Zoom-navigation-transitions not working in tabViewBottomAccessory with a view model

    December 9, 2025

    Computational Approach Stabilizes Metallene for Nanotech

    December 9, 2025

    Subscribe to Updates

    Get the latest technology news from Bigteetechhub about IT, Cybersecurity and Big Data.

      • About Us
      • Contact Us
      • Disclaimer
      • Privacy Policy
      • Terms and Conditions
      © 2025 bigteetechhub.All Right Reserved

      Type above and press Enter to search. Press Esc to cancel.