Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/95.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 连接完成后加载其他函数don';我跑不了?_Objective C_Ios_Uitableview_Nsurlconnection - Fatal编程技术网

Objective c 连接完成后加载其他函数don';我跑不了?

Objective c 连接完成后加载其他函数don';我跑不了?,objective-c,ios,uitableview,nsurlconnection,Objective C,Ios,Uitableview,Nsurlconnection,我使用NSUrlConnection转到.ashx文件,执行MYSQL语句并返回结果。然后把它放在桌子上 在这个特殊的例子中,我得到了分类,这一切都很好,并且得到了它应该得到的细节,但是在ConnectiondFinishLoading函数之后,没有其他事情发生 我将断点放在它后面的任何地方,但没有发生任何事情,它只是在进入表之前结束 下面是我的代码,如果您需要我遗漏的任何信息,请询问 .h文件 #import <UIKit/UIKit.h> @interface

我使用NSUrlConnection转到.ashx文件,执行MYSQL语句并返回结果。然后把它放在桌子上

在这个特殊的例子中,我得到了分类,这一切都很好,并且得到了它应该得到的细节,但是在ConnectiondFinishLoading函数之后,没有其他事情发生

我将断点放在它后面的任何地方,但没有发生任何事情,它只是在进入表之前结束

下面是我的代码,如果您需要我遗漏的任何信息,请询问

.h文件

    #import <UIKit/UIKit.h>

    @interface Category_TableView : UIViewController <NSURLConnectionDelegate>
    {
        sqlite3 *database;
    }
    @property (retain, nonatomic) NSMutableArray *Category_Array;
    @property (strong, nonatomic) IBOutlet UITableView *Category_Table;
    @property (retain, nonatomic) NSString *type;
    @property (retain, nonatomic) NSString *Category;


    @property (retain, nonatomic) NSMutableData *CatData;

    @end
#导入
@接口类别\u表视图:UIViewController
{
sqlite3*数据库;
}
@属性(保留,非原子)NSMutableArray*类别_数组;
@属性(强,非原子)IBUITableView*类别表;
@属性(保留,非原子)NSString*类型;
@属性(保留,非原子)NSString*类别;
@属性(保留,非原子)NSMutableData*CatData;
@结束
.m文件

            #import "Category_TableView.h"
            #import "Cateogry_Cell.h"
            #import "JobList_Table.h"
            #import "JobList_Cell.h"
            #import <QuartzCore/QuartzCore.h>

            @interface Category_TableView ()

            @end

            @implementation Category_TableView

            - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
            {
                self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
                if (self) {
                    // Custom initialization


                }
                return self;
            }

            - (void)viewDidLoad
            {
                [super viewDidLoad];
                self.navigationController.navigationBar.hidden = YES;
                // Do any additional setup after loading the view.

                NSString *requestURL = [NSString stringWithFormat:@"http://"URL"/forms/AppForms/app_latest.ashx"];
                NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString: requestURL]];
                NSURLConnection *con =[[NSURLConnection alloc] initWithRequest:request delegate:self];

                if(con)
                {
                    self.CatData = [[NSMutableData alloc] init];
                    self.Category_Array = [[NSMutableArray alloc] init];
                }
                else
                {
                    [[[UIAlertView alloc] initWithTitle:@"Error" message:@"Failed to get connection. Please try again later" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil] show];
                }

            }
            - (void)didReceiveMemoryWarning
            {
                [super didReceiveMemoryWarning];
                // Dispose of any resources that can be recreated.
            }
            - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
            {
                [self.CatData setLength:0];
            }

            - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
            {
                [self.CatData appendData:data];
            }
            - (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
            {

                [[[UIAlertView alloc] initWithTitle:@"Error" message:@"Failed to get connection. Please try again later"  delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil] show];


            }
            - (void)connectionDidFinishLoading:(NSURLConnection *)connection
            {
                NSString *temp = [[NSString alloc] initWithData:self.CatData encoding:NSUTF8StringEncoding];
                NSArray *jobs = [temp componentsSeparatedByString:@"||||"];
                NSMutableDictionary *temp_dict = [[NSMutableDictionary alloc] init];
                NSArray *jobInfo = [[NSArray alloc] init];
                int count = 0;
                for(int i = 1; i < [jobs count]; i++)
                {
                    jobInfo = [[jobs objectAtIndex:i] componentsSeparatedByString:@"||"];
                    @try {

                        temp_dict = [[NSMutableDictionary alloc]init];
                        [temp_dict setObject:[jobInfo objectAtIndex:0] forKey:@"Category"];
                        [self.Category_Array addObject:temp_dict];
                        count++;
                    }
                    @catch (NSException *exception) {

                        [[[UIAlertView alloc] initWithTitle:@"Exception Thrown" message:exception.reason delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil] show];
                    }
                }
            }


            //#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 [self.Category_Array count];
            }


            - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
            {
                static NSString *CellIdentifier = @"Cateogry_Cell";
                Cateogry_Cell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
                // Configure the cell...


                [[[UIAlertView alloc] initWithTitle:@"In Table Function" message:@"Failed to try again later" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil] show];

                if(cell == nil) {
                    cell = [[Cateogry_Cell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cateogry_Cell"];
                }

                NSDictionary *temp = [self.Category_Array objectAtIndex:[indexPath row]];
                cell.Category_Cell_Label.text = [temp objectForKey:@"Category"];

                return cell;
            }

            -(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
            {
                if ([[segue identifier] isEqualToString:@"Cat_Cell_Push"])
                {
                    JobList_Table *DetailController = [segue destinationViewController];
                    NSIndexPath *MyIndexPath = [_Category_Table indexPathForSelectedRow];
                    int row = [MyIndexPath row];
                    DetailController.JobList_Array = @[_Category_Array[row]];


                }
            }

            @end
#导入“Category_TableView.h”
#导入“cateogray_Cell.h”
#导入“作业列表\表h”
#导入“作业列表\单元格.h”
#进口
@接口类别\u表视图()
@结束
@实现类别\u表视图
-(id)initWithNibName:(NSString*)nibNameOrNil bundle:(NSBundle*)nibBundleOrNil
{
self=[super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
如果(自我){
//自定义初始化
}
回归自我;
}
-(无效)viewDidLoad
{
[超级视图下载];
self.navigationController.navigationBar.hidden=是;
//加载视图后执行任何其他设置。
NSString*requestURL=[NSString stringWithFormat:@“http://”URL“/forms/AppForms/app_latest.ashx”];
NSURLRequest*request=[NSURLRequest requestWithURL:[NSURL URLWithString:requestURL]];
NSURLConnection*con=[[NSURLConnection alloc]initWithRequest:request委托:self];
如果(con)
{
self.CatData=[[NSMutableData alloc]init];
self.Category_Array=[[NSMutableArray alloc]init];
}
其他的
{
[[[UIAlertView alloc]initWithTitle:@“错误”消息:@“无法获取连接。请稍后重试”委托:nil cancelButtontile:@“确定”其他Buttontiles:nil]show];
}
}
-(无效)未收到记忆警告
{
[超级记忆警告];
//处置所有可以重新创建的资源。
}
-(void)连接:(NSURLConnection*)连接DidReceiverResponse:(NSURResponse*)响应
{
[self.CatData setLength:0];
}
-(void)连接:(NSURLConnection*)连接didReceiveData:(NSData*)数据
{
[self.CatData-appendData:data];
}
-(无效)连接:(NSURLConnection*)连接失败错误:(NSError*)错误
{
[[[UIAlertView alloc]initWithTitle:@“错误”消息:@“无法获取连接。请稍后重试”委托:nil cancelButtontile:@“确定”其他Buttontiles:nil]show];
}
-(无效)连接IDFinishLoading:(NSURLConnection*)连接
{
NSString*temp=[[NSString alloc]initWithData:self.CatData编码:NSUTF8StringEncoding];
NSArray*作业=[临时组件由字符串分隔:@“| | | |”];
NSMutableDictionary*temp_dict=[[NSMutableDictionary alloc]init];
NSArray*jobInfo=[[NSArray alloc]init];
整数计数=0;
对于(int i=1;i<[作业计数];i++)
{
jobInfo=[[jobs objectAtIndex:i]组件由字符串分隔:@“| |”];
@试一试{
temp_dict=[[NSMutableDictionary alloc]init];
[temp_dict setObject:[jobInfo objectAtIndex:0]forKey:@“Category”];
[self.Category_Array addObject:temp_dict];
计数++;
}
@捕获(NSException*异常){
[[[UIAlertView alloc]initWithTitle:@“引发异常”消息:Exception.reason委托:nil CancelButtonTile:@“确定”其他ButtonTiles:nil]show];
}
}
}
//#pragma标记-表视图数据源
-(NSInteger)表格视图中的节数:(UITableView*)表格视图
{
//返回节数。
返回1;
}
-(NSInteger)表视图:(UITableView*)表视图行数节:(NSInteger)节
{
//返回节中的行数。
返回[self.Category_数组计数];
}
-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath
{
静态NSString*CellIdentifier=@“Cateogray_Cell”;
cateogray_Cell*Cell=[tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
//配置单元格。。。
[[[UIAlertView alloc]initWithTitle:@“在表函数中”消息:@“稍后重试失败”委托:nil CancelButtontile:@“确定”其他Buttontiles:nil]show];
如果(单元格==nil){
cell=[[Category_cell alloc]initWithStyle:UITableViewCellStyleDefault重用标识符:@“Category_cell”];
}
NSDictionary*temp=[self.Category\u数组objectAtIndex:[indexPa]
[Category_Table reloadData];