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

    The Download: supercharged scams and studying AI healthcare

    April 26, 2026

    How Viasat is providing a blueprint for the industrial edge

    April 26, 2026

    Hampshire College to close: Why colleges are going out of business

    April 26, 2026
    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 – Apply shadow only outside of a SwifUI transparent button?

    April 26, 2026

    ios – How to add pictures after keynote update with iPadOS 26.3.1?

    April 25, 2026

    ios – AVCaptureDevice.exposurePointOfInterest readback does not match set value on iPad Pro M4 / M3(UltraWide)and Gen2,3,4(TrueDepth) using resizeAspectFill

    April 25, 2026
    Add A Comment
    Leave A Reply Cancel Reply

    Editors Picks

    The Download: supercharged scams and studying AI healthcare

    April 26, 2026

    How Viasat is providing a blueprint for the industrial edge

    April 26, 2026

    Hampshire College to close: Why colleges are going out of business

    April 26, 2026

    Bringing Professional-Level Skills to Cisco Networking Academy

    April 26, 2026
    Timer Code
    15 Second Timer for Articles
    20
    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!

    The Download: supercharged scams and studying AI healthcare

    April 26, 2026

    How Viasat is providing a blueprint for the industrial edge

    April 26, 2026

    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
      © 2026 bigteetechhub.All Right Reserved

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