Ошибка инициализации UINib приводит к EXC_BREAKPOINT (код = 1, субкод = 0x1a3a6e6d4) - PullRequest
0 голосов
/ 04 мая 2019

У меня есть приложение для магазина, разработанное в swift 3, и я перешел на swift4 и внес некоторые изменения. В моем приложении все элементы, которые будут инициализировать UINib, вызовут ошибки, которые я не могу отследить по их причине. Xcode ide показывает эту ошибку во время выполнения:

EXC_BREAKPOINT (код = 1, субкод = 0x1a3a6e6d4)

Когда я вызываю такие строки:

let uiNib = UINib(nibName: "ProductCollectionViewCell", bundle: Bundle(identifier: "ProductCollectionViewCell"))

Я сделал это с помощью try / catch, но xCode сказал error block is unrreachable because no errors are thrown.

Обновление:

-------------------------------------------- -------------

Я нашел ошибку из-за этого выражения:

Bundle(identifier: "ProductCollectionViewCell")  

Когда я заменил связку с Nil приложение продолжало и работало без ошибок. Поэтому мне интересно, почему это работает в Swift3, а не в Swift4? ----------------------------------------------- ----------

Вот реализация ProductCollectionViewCell:

ProductDetailsCollectionViewCell.swift

import UIKit
import Alamofire

class ProductDetailsCollectionViewCell: UICollectionViewCell {

    var request: Alamofire.Request?

    @IBOutlet var AlbumImage : UIImageView?
    @IBOutlet var nameLbl: UILabel!
    @IBOutlet var amountLbl: UILabel!

    override func awakeFromNib() {
        super.awakeFromNib()
        amountLbl.textColor = UIColor.productPriceColor()

        if appDelegate.langStr != "en" {
            nameLbl.transform = CGAffineTransform(scaleX: -1.0,y: 1.0)
            amountLbl.transform = CGAffineTransform(scaleX: -1.0,y: 1.0)
            AlbumImage?.transform=CGAffineTransform(scaleX: -1, y: 1);
        }

    }
}

И ProductDetailsCollectionViewCell.xib:

<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="12121" systemVersion="16A323" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
    <device id="retina4_7" orientation="portrait">
        <adaptation id="fullscreen"/>
    </device>
    <dependencies>
        <deployment identifier="iOS"/>
        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12089"/>
        <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
    </dependencies>
    <objects>
        <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
        <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
        <collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="ProductDetailsCollectionViewCell" id="gTV-IL-0wX" customClass="ProductDetailsCollectionViewCell" customModule="nopStation" customModuleProvider="target">
            <rect key="frame" x="0.0" y="0.0" width="190" height="236"/>
            <autoresizingMask key="autoresizingMask"/>
            <view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
                <rect key="frame" x="0.0" y="0.0" width="190" height="236"/>
                <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
                <subviews>
                    <imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="hBd-Mn-wns">
                        <rect key="frame" x="0.0" y="0.0" width="190" height="190"/>
                        <constraints>
                            <constraint firstAttribute="height" constant="190" id="2FA-UQ-OH3"/>
                        </constraints>
                    </imageView>
                    <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="6de-sP-xaI">
                        <rect key="frame" x="76" y="195" width="38" height="18"/>
                        <fontDescription key="fontDescription" type="system" pointSize="15"/>
                        <color key="textColor" red="0.14901960780000001" green="0.18039215689999999" blue="0.1843137255" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                        <nil key="highlightedColor"/>
                    </label>
                    <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Zkv-tA-XgR">
                        <rect key="frame" x="75" y="213" width="40" height="18"/>
                        <fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
                        <color key="textColor" red="0.97647058819999999" green="0.4431372549" blue="0.33725490200000002" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                        <nil key="highlightedColor"/>
                    </label>
                </subviews>
            </view>
            <constraints>
                <constraint firstItem="hBd-Mn-wns" firstAttribute="top" secondItem="gTV-IL-0wX" secondAttribute="top" id="0cp-SG-Lpx"/>
                <constraint firstItem="Zkv-tA-XgR" firstAttribute="top" secondItem="6de-sP-xaI" secondAttribute="bottom" id="2di-Ub-lK2"/>
                <constraint firstItem="6de-sP-xaI" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="gTV-IL-0wX" secondAttribute="leading" constant="8" id="A4b-bR-gbu"/>
                <constraint firstItem="6de-sP-xaI" firstAttribute="top" secondItem="hBd-Mn-wns" secondAttribute="bottom" constant="5" id="FW9-5V-Aq2"/>
                <constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="6de-sP-xaI" secondAttribute="trailing" constant="8" id="FrV-Jw-RGf"/>
                <constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="Zkv-tA-XgR" secondAttribute="trailing" constant="8" id="MFx-al-RxH"/>
                <constraint firstItem="Zkv-tA-XgR" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="gTV-IL-0wX" secondAttribute="leading" constant="8" id="Quz-NU-Ccd"/>
                <constraint firstAttribute="trailing" secondItem="hBd-Mn-wns" secondAttribute="trailing" id="WgC-Z2-lEl"/>
                <constraint firstItem="6de-sP-xaI" firstAttribute="centerX" secondItem="gTV-IL-0wX" secondAttribute="centerX" id="ZDc-E8-UDh"/>
                <constraint firstItem="Zkv-tA-XgR" firstAttribute="centerX" secondItem="gTV-IL-0wX" secondAttribute="centerX" id="bsw-jT-PnR"/>
                <constraint firstItem="hBd-Mn-wns" firstAttribute="leading" secondItem="gTV-IL-0wX" secondAttribute="leading" id="hYC-YL-lcn"/>
            </constraints>
            <size key="customSize" width="467" height="157"/>
            <connections>
                <outlet property="AlbumImage" destination="hBd-Mn-wns" id="biX-F3-owd"/>
                <outlet property="amountLbl" destination="Zkv-tA-XgR" id="oqq-gu-yRa"/>
                <outlet property="nameLbl" destination="6de-sP-xaI" id="qzM-uC-RLP"/>
            </connections>
            <point key="canvasLocation" x="397" y="388"/>
        </collectionViewCell>
    </objects>
</document>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...