Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > Mobile > Mobile Forum > How to NSMutableArray value pass from NSObject to UIViewController in ios ?



 

How to NSMutableArray value pass from NSObject to UIViewController in ios ?

 



Topic : 112810



โพสกระทู้ ( 274 )
บทความ ( 0 )



สถานะออฟไลน์




NSObject.h
Code (Objective-C)
#import <Foundation/Foundation.h>
@interface InvitationList : NSObject

@property (nonatomic, retain) NSMutableArray *myObject;
@property (nonatomic, retain) NSMutableArray *displayObject;
@property (nonatomic, retain) NSDictionary *dict;

@property (nonatomic, retain) NSString *event_id;
@property (nonatomic, retain) NSString *eventname_inv;
@property (nonatomic, retain) NSString *location_inv;
@property (nonatomic, retain) NSString *date_inv;
@property (nonatomic, retain) NSString *image_url;
@property(nonatomic,assign) NSMutableData *receivedData;
-(void)fnPost:(NSString*)pStrVale;
-(NSString *)postMethos;
-(NSMutableArray *)postMethods;

@end



NSObject.m

Code (Objective-C)
#import "InvitationList.h"

@implementation InvitationList
@synthesize event_id,eventname_inv,location_inv,date_inv,image_url;
@synthesize myObject,displayObject,dict;
@synthesize receivedData;

//@synthesize eventname_inv;

-(void)fnPost:(NSString*)pStrVale{
    
    
    event_id = @"eei_event_id";
    eventname_inv = @"ee_event_name";
    location_inv = @"ee_address";
    date_inv = @"ees_event_date";
    image_url = @"ee_event_image_url";

  //    event_id = @"123";
   //  eventname_inv = @"sample";
    
    myObject = [[NSMutableArray alloc] init];
    NSMutableString *post = [NSMutableString stringWithFormat:@"sUserId=%@",pStrVale];
    
    NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
    NSString *postLength = [NSString stringWithFormat:@"%lu", (unsigned long)[postData length]];
    NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@/InvitationList.php",kBaseURL]];
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url
                                                           cachePolicy:NSURLRequestReloadIgnoringLocalCacheData
                                                       timeoutInterval:10.0];
    [request setHTTPMethod:@"POST"];
    [request setValue:postLength forHTTPHeaderField:@"Content-Length"];
    [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
    [request setHTTPBody:postData];
    
    NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
    if (theConnection) {
        self.receivedData = [[NSMutableData data] retain];
        //To show the Indicator
    }else{
        NSLog(@"Connection lost!: Failed to load data");
    }
}
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
    [receivedData setLength:0];
    
}

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
    [receivedData appendData:data];
    
}

- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
    // inform the user
    NSLog(@"Connection failed! Error - %@ %@",[error localizedDescription],[[error userInfo] objectForKey:NSURLErrorFailingURLStringErrorKey]);
}

- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
    if (receivedData) {
        @try{
                id jsonObjects = [NSJSONSerialization JSONObjectWithData:receivedData options:NSJSONReadingMutableContainers error:nil];
                // values in foreach loop
                for (NSDictionary *dataDict in jsonObjects) {
                    NSString *str_event_id = [dataDict objectForKey:@"eei_event_id"];
                    NSString *str_event_name = [dataDict objectForKey:@"ee_event_name"];
                    NSString *str_location = [dataDict objectForKey:@"ee_address"];
                    NSString *str_date = [dataDict objectForKey:@"ees_event_date"];
                    NSString *str_image_url = [dataDict objectForKey:@"ee_event_image_url"];
                    
                    dict = [NSDictionary dictionaryWithObjectsAndKeys:
                            str_event_id, event_id,
                            str_event_name, eventname_inv,
                            str_location, location_inv,
                            str_date, date_inv,
                            str_image_url, image_url,
                            nil];
                    [myObject addObject:dict];
                }
                //displayObject =[[NSMutableArray alloc] initWithArray:myObject];
            
         
            displayObject = [[NSMutableArray alloc] initWithArray:myObject];
            
           // [items postMethods];
                       }
        @catch (NSException *exception) {
            NSLog(@"exception error  %@", exception);
        }
        @finally {
            // Call After working function
        }
    }
    
}



Here, How to displayobject value pass to UIViewController



Tag : Mobile, iOS, iPhone, Objective-C







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2014-11-24 17:30:22 By : vishwa View : 1053 Reply : 2
 

 

No. 1



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

Quote:
myObject = [[NSMutableArray alloc] init];


Current It's Object.






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-11-25 14:30:19 By : mr.win
 


 

No. 2



โพสกระทู้ ( 274 )
บทความ ( 0 )



สถานะออฟไลน์


Thanks mr.win

How can i will pass that object to viewcontroller
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-11-25 16:42:43 By : vishwa
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : How to NSMutableArray value pass from NSObject to UIViewController in ios ?
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 00
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่