Food Tracker "Save" Button

Thank you in advance for your help on the following. I am following the tutorial to the chapter of "Implement Navigation" and got stuck with the Save button. When I click the Save button, Xcode hanged and I have 2 error messages and one sort of warning:


(1) I think this is a warning which doesn't stop the Build and Run but should be addresses. It is :

objc[1575]: Class PLBuildVersion is implemented in both /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/AssetsLibraryServices.framework/AssetsLibraryServices (0x121e40998) and /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/PhotoLibraryServices.framework/PhotoLibraryServices (0x12162a880). One of the two will be used. Which one is undefined.


(2) SIGABRT in the followings:


Thread 1Queue : com.apple.main-thread (serial)


#0
0x000000010ee8edd6 in __pthread_kill ()

SIGABRT at line 5 below

libsystem_kernel.dylib`__pthread_kill:
    0x10ee8edcc <+0>:  movl   $0x2000148, %eax          ; imm = 0x2000148
    0x10ee8edd1 <+5>:  movq   %rcx, %r10
    0x10ee8edd4 <+8>:  syscall
->  0x10ee8edd6 <+10>: jae    0x10ee8ede0               ; <+20>
    0x10ee8edd8 <+12>: movq   %rax, %rdi
    0x10ee8eddb <+15>: jmp    0x10ee87cdf               ; cerror_nocancel
    0x10ee8ede0 <+20>: retq
    0x10ee8ede1 <+21>: nop
    0x10ee8ede2 <+22>: nop
    0x10ee8ede3 <+23>: nop


#11
0x000000010b386c68 in UIApplicationMain ()

SIGABRT at line 47 below

UIKit`UIApplicationMain:
    0x10b386bc9 <+0>:   pushq  %rbp
    0x10b386bca <+1>:   movq   %rsp, %rbp
    0x10b386bcd <+4>:   pushq  %r15
    0x10b386bcf <+6>:   pushq  %r14
    0x10b386bd1 <+8>:   pushq  %r13
    0x10b386bd3 <+10>:  pushq  %r12
    0x10b386bd5 <+12>:  pushq  %rbx
    0x10b386bd6 <+13>:  pushq  %rax
    0x10b386bd7 <+14>:  movq   %rcx, %rbx
    0x10b386bda <+17>:  movq   %rsi, -0x30(%rbp)
    0x10b386bde <+21>:  movl   %edi, %r12d
    0x10b386be1 <+24>:  movq   0xe7f7b8(%rip), %r13      ; (void *)0x000000010aecacb0: objc_retain
    0x10b386be8 <+31>:  movq   %rdx, %rdi
    0x10b386beb <+34>:  callq  *%r13
    0x10b386bee <+37>:  movq   %rax, %r14
    0x10b386bf1 <+40>:  movq   %rbx, %rdi
    0x10b386bf4 <+43>:  callq  *%r13
    0x10b386bf7 <+46>:  movq   %rax, %r15
    0x10b386bfa <+49>:  leaq   0x11dab6b(%rip), %r13     ; _UIApplicationLinkedOnVersion
    0x10b386c01 <+56>:  movl   (%r13), %eax
    0x10b386c05 <+60>:  testl  %eax, %eax
    0x10b386c07 <+62>:  jne    0x10b386c17               ; <+78>
    0x10b386c09 <+64>:  cmpq   $-0x1, 0x11d4ab7(%rip)    ; WebKitSetIsClassic + 7
    0x10b386c11 <+72>:  jne    0x10b386c8a               ; <+193>
    0x10b386c13 <+74>:  movl   (%r13), %eax
    0x10b386c17 <+78>:  cmpl   $0x20100, %eax            ; imm = 0x20100
    0x10b386c1c <+83>:  jb     0x10b386c42               ; <+121>
    0x10b386c1e <+85>:  callq  0x10bfaaa8a               ; symbol stub for: objc_autoreleasePoolPush
    0x10b386c23 <+90>:  movq   %rax, %r13
    0x10b386c26 <+93>:  movl   %r12d, %edi
    0x10b386c29 <+96>:  movq   -0x30(%rbp), %rsi
    0x10b386c2d <+100>: movq   %r14, %rdx
    0x10b386c30 <+103>: movq   %r15, %rcx
    0x10b386c33 <+106>: callq  0x10b386ca2               ; _UIApplicationMainPreparations
    0x10b386c38 <+111>: movq   %r13, %rdi
    0x10b386c3b <+114>: callq  0x10bfaaa84               ; symbol stub for: objc_autoreleasePoolPop
    0x10b386c40 <+119>: jmp    0x10b386c54               ; <+139>
    0x10b386c42 <+121>: movl   %r12d, %edi
    0x10b386c45 <+124>: movq   -0x30(%rbp), %rsi
    0x10b386c49 <+128>: movq   %r14, %rdx
    0x10b386c4c <+131>: movq   %r15, %rcx
    0x10b386c4f <+134>: callq  0x10b386ca2               ; _UIApplicationMainPreparations
    0x10b386c54 <+139>: movq   0x11daa55(%rip), %rdi     ; UIApp
    0x10b386c5b <+146>: movq   0x11489d6(%rip), %rsi     ; "_run"
    0x10b386c62 <+153>: callq  *0xe7f728(%rip)           ; (void *)0x000000010aecdac0: objc_msgSend
    0x10b386c68 <+159>: movq   0xe7f729(%rip), %rbx      ; (void *)0x000000010aecad20: objc_release
    0x10b386c6f <+166>: movq   %r15, %rdi
    0x10b386c72 <+169>: callq  *%rbx
    0x10b386c74 <+171>: movq   %r14, %rdi
    0x10b386c77 <+174>: callq  *%rbx
    0x10b386c79 <+176>: xorl   %eax, %eax
    0x10b386c7b <+178>: addq   $0x8, %rsp
    0x10b386c7f <+182>: popq   %rbx
    0x10b386c80 <+183>: popq   %r12
    0x10b386c82 <+185>: popq   %r13
    0x10b386c84 <+187>: popq   %r14
    0x10b386c86 <+189>: popq   %r15
    0x10b386c88 <+191>: popq   %rbp
    0x10b386c89 <+192>: retq
    0x10b386c8a <+193>: leaq   0x11d4a37(%rip), %rdi     ; _UIApplicationLinkedOnVersionOnce
    0x10b386c91 <+200>: leaq   0xe82d08(%rip), %rsi      ; __block_literal_global.1554
    0x10b386c98 <+207>: callq  0x10bfab2d6               ; symbol stub for: dispatch_once
    0x10b386c9d <+212>: jmp    0x10b386c13               ; <+74>


#12
0x000000010a8bbabf in main at /Users/boscolouie/Desktop/Xcode Projects/FoodTracker/FoodTracker/AppDelegate.swift:12

"Thread 1:signal SIGABRT" shown after line 12 below

/
/
/
/
/
/
/
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
    var window: UIWindow?


#13
0x000000010eb6068d in start ()

"Thread 1:signal SIGABRT" shown after line 3 below

libdyld.dylib`start:
    0x10eb6068c <+0>: nop
    0x10eb6068d <+1>: movl   %eax, %edi
    0x10eb6068f <+3>: callq  0x10eb606c6               ; symbol stub for: exit
    0x10eb60694 <+8>: hlt


#14
0x000000010eb6068d in start ()

"Thread 1:signal SIGABRT" shown after line 3 below

libdyld.dylib`start:
    0x10eb6068c <+0>: nop
    0x10eb6068d <+1>: movl   %eax, %edi
    0x10eb6068f <+3>: callq  0x10eb606c6               ; symbol stub for: exit
    0x10eb60694 <+8>: hlt


Then there is also the following:


libc++abi.dylib: terminating with uncaught exception of type NSException

(lldb)


(3) I suspect there is a problem in unwindToMealList func because there is an empty circle before the line number on the @IBAction func line as per below codes. Empty circle indicates a broken linkage, but the tutorial doesn't ask me to connect this IBAction to anything.


@IBAction func unwindToMealList(sender: UIStoryboardSegue){
       
        if let sourceViewController = sender.source as? MealViewController, let _ = sourceViewController.meal {
       
            /
            let newIndexPath = IndexPath(row: meals.count, section: 0)
           
            tableView.insertRows(at: [newIndexPath], with: .automatic)
        }
    }


Thank you very much for your enlightenment.

Accepted Reply

The code in your unwindToMealList(sender:) method is different to the tutorial; your if statement discards the value of sourceViewController.meal instead of optional-binding that value to a constant named meal and then appending the value of meal to the meals array, and so an internal inconsistency results when tableView attempts to insert a new row.


The tutorial tells you to select that method when connecting the save button to the view controller exit. The circle will continue to be rendered empty after doing so, though. You can select the exit and use the connections inspector to check whether the save button is indirectly connected to the method.

Replies

The code in your unwindToMealList(sender:) method is different to the tutorial; your if statement discards the value of sourceViewController.meal instead of optional-binding that value to a constant named meal and then appending the value of meal to the meals array, and so an internal inconsistency results when tableView attempts to insert a new row.


The tutorial tells you to select that method when connecting the save button to the view controller exit. The circle will continue to be rendered empty after doing so, though. You can select the exit and use the connections inspector to check whether the save button is indirectly connected to the method.

Oh! Thanks a lot. I can move on with the tutorial now though the following error still exist:

"objc[2150]: Class PLBuildVersion is implemented in both /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/AssetsLibraryServices.framework/AssetsLibraryServices (0x121a41998) and /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/PhotoLibraryServices.framework/PhotoLibraryServices (0x12092c880). One of the two will be used. Which one is undefined."

… though the following error still exist:

That’s clearly an Xcode problem. It seems that the (private) PLBuildVersion class is being declared in two different (private) frameworks (AssetsLibraryServices and PhotoLibraryServices) within the simulator, and that causes the Objective-C runtime to kvetch. I don’t expect that this will cause you problems — because both copies of this class were built from the same source code and thus it doesn’t matter which was gets used — however, you should feel free to report a bug describing the exact symptoms under which you’re seeing this error.

Please post your bug number, just for the record.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"