小编Nil*_*shi的帖子

如何在iphone中将NSArray数据分配给NSMutableArray?

在我的应用程序中,我有一个包含一些数据的NSArray.我想把这些数据放入一个NSMutableArray被调用的数据中subArrayData.我能够将我的第一个数组中的数据插入到可变数组中,但是当应用程序运行时,我得到:

警告:从'nsarray*'分配给'nsmutablearray*'的指针类型不兼容请帮帮忙.

以下是我的代码:.h文件

#import <UIKit/UIKit.h>

@interface AddNew : UIViewController
{
    NSMutableArray *subArrayData;;
}
@property(nonatomic ,retain)NSMutableArray *subArrayData;
Run Code Online (Sandbox Code Playgroud)

.m文件

#import "AddNew.h"
#import "DashBoardPage.h"
#import "SubmitYourListing.h"


@implementation AddNew

@synthesize subArrayData;

-(void)accommodationAndTravel
{
    subArrayData =[[NSArray alloc] initWithArray:[NSArray arrayWithObjects:@"Select one",@"Accommodation and travel hospitality",@"Apartments and villas",@"Bed and Breakfast",@"Caravan parks and campsites",@"Hospitality",
                                                  @"Hotels and Motels",@"Snow and Ski lodges",@"Tourist attractions and tourism information",@"Tours and Holidays",@"Travel agents and Services",nil]];


}
Run Code Online (Sandbox Code Playgroud)

iphone object objective-c ios xcode4.2

9
推荐指数
3
解决办法
2万
查看次数

以编程方式将SQLite数据导出到iOS中的Excel

在我的应用程序中,我使用sqlite作为后端(本地存储数据).我能够将数据插入到我的表中.但我想要做的是,想要以编程方式将所有我的sqlite数据导入到excel中.我不想为这个app使用服务器.如果excel表是生成用户应该能够邮寄那张表.这可能在iPhone中:请帮助我.

以下是我将数据插入表中的代码:

-(IBAction)Login
{
sqlite3_stmt *stmt;
        char *errorMsg; 
        char *update1 = "insert into Login1 values (?,?,?,?);";
        int x = sqlite3_prepare_v2(database, update1, -1, &stmt, nil);

    if (x == SQLITE_OK) 
    { 
        sqlite3_bind_text(stmt, 1, NULL,-1, NULL);
        sqlite3_bind_text(stmt, 2, [USERID UTF8String],-1, NULL);
        sqlite3_bind_text(stmt, 3, [str1 UTF8String],-1, NULL);
        sqlite3_bind_text(stmt, 4, [str4 UTF8String],-1, NULL);


    } 

    if (sqlite3_step(stmt) != SQLITE_DONE)
        NSLog(@"Error: %@",errorMsg); 
    sqlite3_finalize(stmt);
Run Code Online (Sandbox Code Playgroud)

}

sqlite iphone objective-c ios

9
推荐指数
1
解决办法
1万
查看次数

如何将数据从详细视图控制器传递回uitableview?

在我的应用程序中,我使用uitable从我的列表中选择类别.我的任务是,当用户点击或选择一个单元格时,他应该能够在下一个视图(详细视图)中查看所选的单元格细节.当他在详细视图中选择项目时,他应该能够在表格视图中向后移动,并且应该能够在rootivew控制器中查看所选项目.

我能够从tableview正确导航到详细视图,但我无法在rootviewcontroller的详细视图中显示所选的项目.

请帮我解决这个问题.

在此输入图像描述 图像一是我的rootview控制器页面.例如:如果用户选择@"make",他将能够看到@"make"的所有相关类别.在下一页(哪个image2).

在此输入图像描述 image to是我的详细页面.

当用户选择@"abarth"时,它应该显示在rootview控制器页面(第一页)中.

以下是我的rootview控制器页面代码:

- (void)viewDidLoad
{

    self.car = [[NSArray alloc]initWithObjects:@"Make",@"Model",@"Price Min",@"Price Max",@"State",nil];


    [super viewDidLoad];

}

-(NSInteger) numberOfSectionInTableView:(UITableView *)tableView
{
    return 1;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [self.car count];
}



-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *TextCellIdentifier = @"Cell";

    UITableViewCell *cell =[tableView dequeueReusableCellWithIdentifier:TextCellIdentifier];
    if (cell==nil) 
    {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:TextCellIdentifier];
        cell.accessoryType = UITableViewCellAccessoryNone;
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }

        cell.textLabel.text = [self.car objectAtIndex:[indexPath row]];
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;





       return cell;
}



- (void)tableView:(UITableView *)tableView 
didSelectRowAtIndexPath:(NSIndexPath …
Run Code Online (Sandbox Code Playgroud)

iphone xcode objective-c ios4 xcode4

6
推荐指数
1
解决办法
7211
查看次数

iPhone使用smtp服务器发送电子邮件?

在我的应用程序中,我能够使用smtp服务器发送电子邮件,因为我输入了正确的电子邮件ID和密码.但当我输入我的Gmail或雅虎帐户详细信息时,我无法发送邮件.因为我设置了relayHost = @"smtp.gmail.com"; 然后我也无法发送邮件.

请帮我解决这个问题.

以下是我的代码:

-(void)sendEMAIL{

   SKPSMTPMessage *testMsg = [[SKPSMTPMessage alloc] init];

    testMsg.fromEmail = str_uname;
    NSLog(@"str_Uname=%@",testMsg.fromEmail);

    testMsg.toEmail = str_info;

    NSLog(@"autoemail=%@",testMsg.toEmail);

    testMsg.relayHost = @"smtp.gmail.com";

    testMsg.requiresAuth = YES;

    testMsg.login = str_uname;
    NSLog(@"autoelogin=%@",testMsg.login);

    testMsg.pass = str_password;
    NSLog(@"autopass=%@",testMsg.pass);

   testMsg.subject = @"Schedule Sms And Email";

   testMsg.wantsSecure = YES; 

   NSString *sendmsg=[[NSString alloc]initWithFormat:@"%@",str_info2];
   NSLog(@"automsg=%@",sendmsg);

   testMsg.delegate = self;

   NSDictionary *plainPart = [NSDictionary dictionaryWithObjectsAndKeys:@"text/plain",kSKPSMTPPartContentTypeKey,
                           sendmsg, kSKPSMTPPartMessageKey,@"8bit",kSKPSMTPPartContentTransferEncodingKey,nil];

    testMsg.parts = [NSArray arrayWithObjects:plainPart,nil];
    [testMsg send];
}

-(void)messageSent:(SKPSMTPMessage *)message{ 
   [message release];     
}

-(void)messageFailed:(SKPSMTPMessage *)message error:(NSError *)error{
   [message release];
}
Run Code Online (Sandbox Code Playgroud)

iphone xcode objective-c ios4

5
推荐指数
1
解决办法
6745
查看次数

如何以编程方式添加 UITabBarItem?

在我的应用程序中,我添加UITabBarController了“Storyborad”。但现在我想以UITabBarItem编程方式添加。假设有 5 个按钮,每当用户单击该按钮时,UITabBarController就会调用my 。“标签栏”中共有 5 个标签。例如:

选项卡名称:项目 1、项目 2、项目 3、项目 4、项目 5。按钮名称:item1、item2、item3、item4、item5。

假设用户单击 item1 按钮UITabBarcontroller被调用。现在用户应该无法在“tabbarcontroller”中看到 item1 选项卡,他应该能够看到重置的“tabBaritem”。

谁能帮我解决这个问题?如何以编程方式做到这一点?

谢谢。

尼勒什

objective-c uitabbarcontroller uitabbaritem ios ios7

5
推荐指数
1
解决办法
5545
查看次数

如何在iPhone应用程序中实现PSCollectionView?

在我的应用程序中,我有六个按钮,需要放在pscollectionview上.我已经在应用程序中放置了pscollectionview但我不是在使用数据源和委托方法吗?任何人想出这个例子都会有帮助吗?以下是我的代码:

- (void)viewDidLoad
{

    self.collectionView = [[PSCollectionView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];


    self.collectionView.delegate = self;
    self.collectionView.collectionViewDelegate = self;
    self.collectionView.collectionViewDataSource = self;
    self.collectionView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
    [self.view addSubview:self.collectionView];


    UIButton *btn1 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    btn1.frame = CGRectMake(10, 30, 140, 130);
    [self.collectionView addSubview:btn1];

    UIButton *btn2 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    btn2.frame = CGRectMake(170, 30, 140, 130);
    [self.collectionView addSubview:btn2];

    UIButton *btn3 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    btn3.frame = CGRectMake(10, 180, 140, 130);
    [self.collectionView addSubview:btn3];

    UIButton *btn4 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    btn4.frame = CGRectMake(170, 180, 140, 130);
    [self.collectionView addSubview:btn4]; …
Run Code Online (Sandbox Code Playgroud)

iphone objective-c ios xcode4 ios5

2
推荐指数
1
解决办法
2192
查看次数

iOS解析JSON?

我从服务器得到以下响应

[{"id":"16","name":"Bob","age":"37"},{"id":"17","name":"rob","age":"28"}];
Run Code Online (Sandbox Code Playgroud)

我正在使用AFNetworking框架,

我得到上面的响应NSData,然后使用下面的代码,我能够收集数据NSDictionary

NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingAllowFragments error:&error];
Run Code Online (Sandbox Code Playgroud)

但是如何从中解析"name"和"age"价值NSDictionary呢?

objective-c nsjsonserialization

1
推荐指数
1
解决办法
488
查看次数