返回列表 回覆 發文

[Xcode] 遇到了一個error

本帖最後由 cii84fd 於 2010-2-8 16:12 編輯

錯誤訊息
command/developer/platforms/iphonesimulator.platform/developer/usr/bin/gcc-4.2 failed with exit code 1

不知道錯在哪裡.. 卡在這個問題快第四天了...
請問版上的大大有人知道這是哪裡的error造成的嗎?
因為我寫了二個view故要把二個view合在一個程式執行..
分開都可以跑 合起來就出現這個error了

有那位大大可以幫我 我不想帶著這個問題過年啊~~~  0rz
可不可以換顆腦袋... 0rz
[會心一笑]:
iDevtw真是神奇的地方... 才PO上來...我自己就把困4天的error解開了
之前也發生一樣的情況 不過解開後我還有個觀念的問題 所以我又卡關了 (淚)

以Tab bar來製作的應用程式
在AppDelegate.h  的宣告
@interface New_versionAppDelegate : NSObject <UIApplicationDelegate, UITabBarControllerDelegate> {
    UIWindow *window;
    UITabBarController *tabBarController;
        UIViewController *vc1;
    SecondViewController *viewsecond; //SecondViewController 為TabBarController的第二個view

在 viewController.m 呼叫viewsecond
[self.tabBarController pushViewController:anotherViewController animated:YES];

會出現 error:request for member'viewsecond' in something not a stucture or union
若將viewsecond 改為tabBarController卻可run 請問在線上的大大要怎麼才能把pushViewController載入?

期待能有善心的大大來幫我解惑 謝謝!!
可不可以換顆腦袋... 0rz
[會心一笑]:
看不太懂,還有可以用程式碼標籤把程式碼包住,比較好閱讀
[會心一笑]:
SecondViewController 的形態為何?
把定義拿出來看
100 字節以內
不支持自定義 Discuz! 代碼
[會心一笑]:
請問你有沒有 import SecondViewController  的 .h 檔?
程式可能要貼完整一點,不然還真搞不懂是那錯了!
說不定錯的地方,你沒貼到?!
好康集點王:http://www.conn.tw/5031074
書、呆子、碎碎念 http://mebookfan.pixnet.net/blog
[會心一笑]:
本帖最後由 cii84fd 於 2010-2-9 14:18 編輯
SecondViewController 的形態為何?
把定義拿出來看
cseserv 發表於 2010-2-8 17:48
C大說的沒對,我真的對定義那些很模糊..都是看範例再更改它的方法實現為自己想要的功能
所以可能觀念搞錯了.. 想請問定義的資料去哪裡找比較好分辦各controller各個形態呢 謝謝C大
看不太懂,還有可以用程式碼標籤把程式碼包住,比較好閱讀
cfc 發表於 2010-2-8 17:40
不好意思..沒發現有這個功能 現在補上程式碼標籤 :)
請問你有沒有 import SecondViewController  的 .h 檔?
程式可能要貼完整一點,不然還真搞不懂是那錯了!
...
vic888 發表於 2010-2-8 21:45
我有improt SecondViewController.h在AppDelegate內
我把所有呼叫到的.h .m都補上了
謝謝大家願意為我解答  也請大家不吝伺教 
我會很虛心地接受的 謝謝!! 

New_versionAppDelegate.h
  1. #import <UIKit/UIKit.h>


  2. @interface New_versionAppDelegate : NSObject <UIApplicationDelegate, UITabBarControllerDelegate> {
  3.     UIWindow *window;
  4.     UITabBarController *tabBarController;
  5.         UIViewController *vc1;
  6.         SecondViewController *viewsecond;
  7.        
  8. }

  9. @property (nonatomic, retain) IBOutlet UIWindow *window;
  10. @property (nonatomic, retain) IBOutlet UITabBarController *tabBarController;
  11. @property (nonatomic, retain) IBOutlet UIViewController *vc1;
  12. @property (nonatomic,retain) SecondViewController *viewsecond;
  13. @end
複製代碼
New_versionAppDelegate.m
  1. #import "SecondViewController.h"
  2. #import "New_versionAppDelegate.h"

  3. @implementation New_versionAppDelegate
  4. @synthesize window;
  5. @synthesize tabBarController;
  6. @synthesize vc1;
  7. @synthesize viewsecond;

  8. - (void)applicationDidFinishLaunching:(UIApplication *)application {
  9.    
  10.     // Add the tab bar controller's current view as a subview of the window
  11.     [window addSubview:tabBarController.view];
  12.         [window makeKeyAndVisible];
  13. }

  14. - (void)dealloc {
  15.     [tabBarController release];
  16.     [window release];
  17.     [super dealloc];
  18. }

  19. @end
複製代碼
SecondViewController.h
  1. #import <UIKit/UIKit.h>
  2. #import "RSSParser.h"



  3. @interface SecondViewController : UITableViewController {
  4.         NSMutableArray *xmlContent;
  5.         RSSParser *parser;

  6. }

  7. @end
複製代碼
SecondViewController.m
  1. #import "SecondViewController.h"
  2. #import "New_versionAppDelegate.h"
  3. #import "RSSObject.h"
  4. #import "RSSParser.h"
  5. #import "RSSContentViewController.h"


  6. @implementation SecondViewController

  7. - (void)viewDidLoad {
  8.     [super viewDidLoad];
  9.         // 抓取資料
  10.         NSURL *url = [NSURL URLWithString:@"http://nrl.iis.sinica.edu.tw/Yushan/yushanapi/getTrace.php?ln=%E9%99%B3&fn=%E4%BD%91%E4%B8%80&id4=0000&bd=1980-01-01&dhtId=1"];
  11.         parser = [[RSSParser alloc] init];
  12.         [parser parseWithUrl:url];
  13.         xmlContent = [parser result];
  14.         self.navigationItem.title = @"XML Reader";

  15. }


  16. - (void)didReceiveMemoryWarning {
  17.     [super didReceiveMemoryWarning];

  18. }


  19. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  20.     return 1;
  21. }


  22. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  23.     return [xmlContent count];

  24. }

  25. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

  26.     static NSString *CellIdentifier = @"Cell";
  27.    
  28.     UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  29.     if (cell == nil) {
  30.         cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
  31.     }
  32.    
  33.             // 自記憶體內容取出,自結果內容取出
  34.         NSInteger row = [indexPath row];
  35.         RSSObject *rss = [xmlContent objectAtIndex:row];
  36.         [cell setText:rss.chName];//在這個畫面顯示標題

  37.     return cell;
  38. }

  39. //處理使用者點選表格的動作,也就是切換到另一個View並顯示新聞內容
  40. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  41.         RSSContentViewController *anotherViewController = [[RSSContentViewController alloc] initWithNibName:@"RSSContent" bundle:nil];
  42.         NSInteger row = [indexPath row];
  43.         RSSObject *rss = [xmlContent objectAtIndex:row];
  44.                
  45.         //取出所有內容
  46.         [anotherViewController setText:[NSString stringWithFormat:@"%@ \n%@  \n%@ \n  ",rss.pointDesc ,rss.dateDesc,rss.timeDesc]];
  47.         [self.viewsecond pushViewController:anotherViewController animated:YES];
  48.         [anotherViewController release];
  49.        
  50. }

  51. - (void)dealloc {
  52.     [super dealloc];
  53.         [xmlContent release];
  54.         [parser release];
  55. }


  56. @end
複製代碼
可不可以換顆腦袋... 0rz
[會心一笑]:
In New_versionAppDelegate.h
  1. #import <UIKit/UIKit.h>
  2. #import "SecondViewController.h"

  3. @class SecondViewController
複製代碼
這樣試試
[會心一笑]:
返回列表