한국어

스마트폰앱

온누리070 플레이스토어 다운로드
    acrobits softphone
     온누리 070 카카오 프러스 친구추가온누리 070 카카오 프러스 친구추가친추
     카카오톡 채팅 상담 카카오톡 채팅 상담카톡
    
     라인상담
     라인으로 공유

     페북공유

   ◎위챗 : speedseoul


  
     PAYPAL
     
     PRICE
     

pixel.gif

    before pay call 0088 from app


https://stackoverflow.com/questions/36660940/how-to-set-value-for-object-in-objective-c


-4

I am new to ios programming,i created a class books which takes some values dynamically,so i am trying to set value for some params in book object,i am getting exception.

code:

Book
{
@property (strong,nonatomic)  NSString *bookId;
@property (strong,nonatomic)  NSString *bookStatus;
@property (strong,nonatomic)  NSString *bookName;
 }
Book * book =[Book alloc]init];
[book setValue:@"textbook" forKey:@"bookName"]; //not working
book.bookStatus=@"textbook"  //not working
[book setbookStatus:@"textbook"];  //not working
}

I am getting exception [_NSCFDictionary setbookStatus] unrecognized selector

  • 1
    Is this your actual code? How is you Book class defined? What is the @interface code? The exception shows that you tried to call setBookStatus on an instance of NSDictionary. You can just say book.bookName=@"textbook"; – Paulw11 Apr 16 '16 at 6:36 
  • try book.bookName = @"bookName" – Prashant Tukadiya Apr 16 '16 at 6:37
  • i wrote code in shorter format for understanding,i tried but still getting exception @PKT – skyshine Apr 16 '16 at 6:39
-1

Simply you can use,

self.bookName = @"yourBookName";
self.bookStatus = @"bookStatus";

You can use self to call current class object likw this in java.

If you want to access it from another class then import Book to that class and make instance of it and by that instance you can call it,s property like,

Book *myBook = [[Book alloc]init];
NSString *str = myBook.bookName;

hope this will help ;)

-1

Create the properties in the .h(Book.h) class to make properties as public. Then you can directly access the properties by dot(.)

Book *book = [[Book alloc] init];
book.bookId = @“1234
book.bookName = @“name
조회 수 3969
조회 수 3866
조회 수 5372
조회 수 4202
조회 수 4416
조회 수 4365
조회 수 4217
조회 수 4562
조회 수 4193
조회 수 4242
조회 수 4592
iOS Swipe Gesture 정리
admin
2019.05.04
조회 수 11534
조회 수 4374