-4

I don't know a lot about XCode. Well, I know amlost nothin about XCode. But I am having a problem with the TableView.

I was following This Tutorial but when I try to make it myself, everything works out perfectly except for the TableView items. All tutorials that i've tried that involve table view, give me the same problem. No items are showed :( I am going to leave a download link with the full project, because i'm not sure what code you guys need to help me.

Download Link (MediaFire)

Please HELP! My head is about to explode ....

This is the error i'm getting when I try to run the app.

//
//  main.m
//  Demo TWo
//
//  Created by Alexander Pina on 2/18/13.
//  Copyright (c) 2013 Alexander Pina. All rights reserved.
//

#import <UIKit/UIKit.h>

#import "AppDelegate.h"

int main(int argc, char *argv[])
{
    @autoreleasepool {
        return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
    }
}

In the @autoreleasepoo { ... It tells me, "Thread 1: signal SIGABRT

AlexPjz
  • 33
  • 4

3 Answers3

0

add delegate & dataSource. i think you are forgotten to add delegates &dataSource thats why its not showing table. add following lines to your viewDidLoad().like below code

self.myTableView.dataSource = self;
  self.myTableView.delegate = self;
Ravindra Bagale
  • 17,226
  • 9
  • 43
  • 70
0

I looked at your project. Your problem, I think, is caused by a bug in Xcode. This can happen in hooking up xib or Storyboard files and I've run into issues a number of times after changing certain things in the File Inspector of a xib file.

Your Tab2_TableViewController class code was not being used, even though you set the custom class name of your UITableViewController to Tab2_TableViewController in the storyboard. I tested this by putting a breakpoint in the viewDidLoad of you Tab2_TableViewController subclass and seeing that method was never called. It should work, but something was messed up in Xcode so it wasn't working.

I solved the problem by doing this:

  • copying the Tab2_TableViewController.h and .m files to another folder
  • deleting the Tab2_TableViewController.h and .m from the Xcode project
  • copying the Tab2_TableViewController.h and .m from the other folder back into the Xcode project.

That's all I did and it solved the problem, the table view cells are now being loaded into the view.


Actually I found a better way to fix the issue. In the Xcode Project Navigator, select the project file. Select the target DemoTWo->Build Phases->Compile Sources. Hit the little '+' button and add Tab2_TableViewController.m. Normally when you add files they are automatically added to this list, but for whatever reason that file wasn't added in your case.

enter image description here

Darren
  • 10,091
  • 18
  • 65
  • 108
  • Hey. Can you send me your project? Or paste a link here? Because I did what you said and now it's giving me a weird error: "0x3b0a7350: blo 0x3b0a7368 ; __pthread_kill + 32" – AlexPjz Feb 19 '13 at 15:57
  • I found a better solution to your problem, see my updated answer. If you do this on the original project that you posted, it should work. I can't tell why you're getting that error, although you could try to run clean on your project and see if that resolves it. – Darren Feb 19 '13 at 16:20
  • Ok so I did that with my project, and it wasnt running. So I re-downloaded the file I uploaded and it ran. But when I did this, another error was occuring. So I decided to restart my laptop and download the project again, and still :( Can you upload a version of your project so I can try with that one? – AlexPjz Feb 19 '13 at 16:31
  • OK, you can grab it from here: http://www.yousendit.com/download/UW13c2ZDeFVTRTdOTzhUQw – Darren Feb 19 '13 at 16:38
  • Same error. I run the app both on my iPhone and the Simulator. Im going to upload a pic wait. http://i.imgur.com/0JrzOx1.png – AlexPjz Feb 19 '13 at 16:42
  • Try deleting the app from your simulator and running Project->Clean before building again. Also, to get a more useful error feedback, try adding an exception breakpoint: http://stackoverflow.com/a/14767076/472344 – Darren Feb 19 '13 at 16:51
  • I tried that and the same error. Breakpoints; it said there are no breakpoints. Should I download an older version of XCode? – AlexPjz Feb 19 '13 at 17:07
  • No, add an exception breakpoint yourself, following the instructions in the link I posted. – Darren Feb 19 '13 at 17:19
  • Oh I see what the problem is. In the storyboard, change the custom class name of the Item 1 view controller from Tab2_TableViewController to Tab1_ViewController. – Darren Feb 19 '13 at 17:29
  • Try this project: http://www.yousendit.com/download/UW13c2ZJeDN0NjlWeHNUQw – Darren Feb 19 '13 at 17:31
  • I haven't found that tutorial useful. The buttons they talk about are different in my version. I did do something but I'm not sure if its right. Do you think we can do a voice chat or hangout on google+ or whatever other service provider? It would be much easier if I just show you what I'm getting and you guide me trhough. Thanks for all your help BTW! – AlexPjz Feb 19 '13 at 17:57
  • I didn't see your last 2 responses. I'm in college right now, but I will surely try that when I get home! Thank you very much! – AlexPjz Feb 19 '13 at 17:58
  • Working perfectly! But why does my XCode simulate the app as if it didn't have iPhone 5 support? – AlexPjz Feb 19 '13 at 20:10
  • See here for adding iPhone 5 support: http://stackoverflow.com/a/12397309/472344 (you also have to change the simulator screen size by going to Hardware->Device) – Darren Feb 19 '13 at 20:46
  • Ok perfect! Can you contact me on my e-mail? I would like to have your contact information just for future refference. Since I still can't make a "chat" because people vote down on my questions. Anyways.. here: explodee94@gmail.com thanks again. – AlexPjz Feb 20 '13 at 02:52
  • Hey, I answered your other question. You will be better off continuing to post questions here than corresponding with me by email, as I often won't have time to answer, and there are many more people here that can help. I'm sure you'll get the hang of what type of questions to ask here soon if you look around at some of the other posts. Good luck! – Darren Feb 20 '13 at 05:37
-1

Try this,

->Simply create single View Application based sample project in your xcode

ViewController.h

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController<UITableViewDataSource,UITableViewDelegate>

{
IBOutlet UITableView *TableView;
NSArray *arrItems;
}
@end

viewcontroller.m

     #import "ViewController.h"
     @interface ViewController ()

     @end

     @implementation ViewController

      - (void)viewDidLoad
     {
         [super viewDidLoad];
         arrItems =[[NSArray alloc]initWithObjects:@"row1",@"row2",@"row3",@"row4",@"row5",@"row6",@"row7", nil];
        TableView.dataSource =self;
         TableView.delegate =self;
// Do any additional setup after loading the view, typically from a nib.
     }
        #pragma mark -
        #pragma mark Table view data source

      - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
         // Return the number of sections.
         return 1;
         }


      - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
         // Return the number of rows in the section.
      return [arrItems count];
              }


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

        static NSString *CellIdentifier = @"Cell";

       UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
         if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];

    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    [cell.textLabel setFont:[UIFont boldSystemFontOfSize:16]];
    [cell.textLabel setTextColor:[UIColor colorWithRed:0 green:0.5 blue:0 alpha:1]];
          }

    cell.textLabel.text = [arrItems objectAtIndex:indexPath.row];
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    return cell;
         }



     #pragma mark -
     #pragma mark Table view delegate

         - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {


         }
Ravindhiran
  • 5,304
  • 9
  • 50
  • 82
  • I tried this, but it didn't work. I don't know if I did it the right way though. I placed all those codes in the right place, but from here and on what I did was, create a new TableViewController and in the "Identitiy" I wrote "Cell". What else do I have to do? – AlexPjz Feb 19 '13 at 04:36
  • simply create Viewcontroller enough No need to create UITableViewController then drag and drop tableView not a tableView cell and then follow posted code – Ravindhiran Feb 19 '13 at 04:45