2016-02-16 68 views
0

enter image description here的XCode 7:連接器的命令,退出代碼1失敗(使用-v看到調用)

Ld /Users/Abhinav/Library/Developer/Xcode/DerivedData/UsingSegue-bujjpyciairreubqxbgfqixpwbiv/Build/Products/Debug-iphonesimulator/UsingSegue.app/UsingSegue normal i386 
    cd "/Users/Abhinav/Desktop/Fist Project/UsingSegue" 
    export IPHONEOS_DEPLOYMENT_TARGET=9.2 
    export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" 
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang 
-arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk 
-L/Users/Abhinav/Library/Developer/Xcode/DerivedData/UsingSegue-bujjpyciairreubqxbgfqixpwbiv/Build/Products/Debug-iphonesimulator 
-F/Users/Abhinav/Library/Developer/Xcode/DerivedData/UsingSegue-bujjpyciairreubqxbgfqixpwbiv/Build/Products/Debug-iphonesimulator 
-filelist /Users/Abhinav/Library/Developer/Xcode/DerivedData/UsingSegue-bujjpyciairreubqxbgfqixpwbiv/Build/Intermediates/UsingSegue.build/Debug-iphonesimulator/UsingSegue.build/Objects-normal/i386/UsingSegue.LinkFileList 
-Xlinker -rpath -Xlinker @executable_path/Frameworks -mios-simulator-version-min=9.2 -Xlinker -objc_abi_version -Xlinker 2 -fobjc-arc -fobjc-link-runtime -Xlinker -dependency_info -Xlinker /Users/Abhinav/Library/Developer/Xcode/DerivedData/UsingSegue-bujjpyciairreubqxbgfqixpwbiv/Build/Intermediates/UsingSegue.build/Debug-iphonesimulator/UsingSegue.build/Objects-normal/i386/UsingSegue_dependency_info.dat 
-o /Users/Abhinav/Library/Developer/Xcode/DerivedData/UsingSegue-bujjpyciairreubqxbgfqixpwbiv/Build/Products/Debug-iphonesimulator/UsingSegue.app/UsingSegue 

duplicate symbol _OBJC_IVAR_$_NextViewController._NextArray in: 
    /Users/Abhinav/Library/Developer/Xcode/DerivedData/UsingSegue-bujjpyciairreubqxbgfqixpwbiv/Build/Intermediates/UsingSegue.build/Debug-iphonesimulator/UsingSegue.build/Objects-normal/i386/ViewController.o 
    /Users/Abhinav/Library/Developer/Xcode/DerivedData/UsingSegue-bujjpyciairreubqxbgfqixpwbiv/Build/Intermediates/UsingSegue.build/Debug-iphonesimulator/UsingSegue.build/Objects-normal/i386/NextViewController.o duplicate symbol _OBJC_CLASS_$_NextViewController in: 
    /Users/Abhinav/Library/Developer/Xcode/DerivedData/UsingSegue-bujjpyciairreubqxbgfqixpwbiv/Build/Intermediates/UsingSegue.build/Debug-iphonesimulator/UsingSegue.build/Objects-normal/i386/ViewController.o 
    /Users/Abhinav/Library/Developer/Xcode/DerivedData/UsingSegue-bujjpyciairreubqxbgfqixpwbiv/Build/Intermediates/UsingSegue.build/Debug-iphonesimulator/UsingSegue.build/Objects-normal/i386/NextViewController.o duplicate symbol _OBJC_METACLASS_$_NextViewController in: 
    /Users/Abhinav/Library/Developer/Xcode/DerivedData/UsingSegue-bujjpyciairreubqxbgfqixpwbiv/Build/Intermediates/UsingSegue.build/Debug-iphonesimulator/UsingSegue.build/Objects-normal/i386/ViewController.o 
    /Users/Abhinav/Library/Developer/Xcode/DerivedData/UsingSegue-bujjpyciairreubqxbgfqixpwbiv/Build/Intermediates/UsingSegue.build/Debug-iphonesimulator/UsingSegue.build/Objects-normal/i386/NextViewController.o ld: 3 duplicate symbols for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation) 

我檢查我的編譯源代碼,有沒有重複出現,還是我得到這個錯誤。 我是IOS新手,有人請幫忙。 我想在視圖控制器中創建數組,然後將它傳遞給使用segues的另一個視圖控制器。

ViewController.m:

-(IBAction)click:(id)sender 
    { 
    self.ArrayInput = [[NSMutableArray alloc]init]; 
    [self.ArrayInput addObject:@[_firstname.text]]; 
    [self.ArrayInput addObject:@[_lastname.text]]; 
    [self.ArrayInput addObject:@[_Email.text]]; 

NextViewController * nextcontroller = (NextViewController *)[self.storyboard  instantiateViewControllerWithIdentifier:@"NextViewController"]; 
[self.navigationController pushViewController:nextcontroller animated:YES]; 

} 

然後使用賽格瑞在ViewController.m:

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender 
{ 
NextViewController * NextVC = (NextViewController *)segue.destinationViewController; 
NextVC.NextArray = [NSMutableArray arrayWithArray:self.ArrayInput]; 

} 

NextViewController.m:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath 
    { 
     myTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"myTableViewCell" forIndexPath:indexPath]; 
     cell.Data.text = [self.NextArray objectAtIndex:indexPath.row]; 

    return cell; 

} 

回答

3

這種錯誤經常發生意外導入。 m文件而不是.h

OR

步驟:

  1. 在目標設置檢查建造階段。
  2. 檢查是否有文件存在兩次或一次。
  3. 如果文件存在兩次刪除一個。
+0

再次檢查我的代碼..在NextViewController.m中聲明nsmutablearray ...必須在NextViewController.h中創建數組,並在ViewController.m中包含NextViewController.h文件..解決了我的問題..謝謝.. – ABJ

-1

再次檢查我的代碼..宣佈的NSMutableArray在NextViewController.m ......不得不創造NextViewController.h陣列幷包含在ViewController.m的NextViewController.h文件..解決了我的問題..謝謝。

相關問題