Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9135305
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:48:24+00:00 2026-06-17T08:48:24+00:00

I have the Header of this class in my project: @interface VideoItem : NSObject

  • 0

I have the Header of this class in my project:

    @interface VideoItem : NSObject <NSCoding> {
        NSString *idStr;
        NSString *name;
        NSString *link;
    }

    -(id)initWithVideoItem:(VideoItem*)video;

    @property (nonatomic, retain) NSString *name;
    @property (nonatomic, retain) NSString *link;
    @property (nonatomic, retain) NSString *idStr;

    @end

this is the implement:

@implementation VideoItem
@synthesize name,link,idStr;

-(id)initWithVideoItem:(VideoItem*)video{
    if (self = [super init]) {
        self.name = video.name;
        self.link = video.link;
        self.idStr = video.idStr;
    }
    return self;
}

#pragma mark 
#pragma mark NSCoder

- (void)encodeWithCoder:(NSCoder *)encoder{
    [encoder encodeObject:self.name forKey:@"video_name"];
    [encoder encodeObject:self.link forKey:@"video_link"];  
    [encoder encodeObject:self.idStr forKey:@"video_id"];   
    [encoder encodeObject:self.imgUrl forKey:@"video_img"];
    [encoder encodeObject:self.viewCount forKey:@"video_views"];
    [encoder encodeObject:self.artist forKey:@"video_artist"];
    [encoder encodeObject:self.timeStr forKey:@"video_timestr"];    
    [encoder encodeInt:self.seconds forKey:@"video_secondes"];
    [encoder encodeInt:self.rating forKey:@"video_rating"];
    [encoder encodeObject:self.pubDate forKey:@"pubDate"];

}

- (id)initWithCoder:(NSCoder *)decoder {
    if(self = [super init]){
        self.name = [decoder decodeObjectForKey:@"video_name"];
        self.link = [decoder decodeObjectForKey:@"video_link"]; 
        self.idStr = [decoder decodeObjectForKey:@"video_id"];
    }
    return self;
}

@end

And i want to know if in case like this i need to add dealloc method and release the strings or not?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T08:48:25+00:00Added an answer on June 17, 2026 at 8:48 am

    Yes you should release the strings because when using the properties that retain objects.

    - (void)dealloc {
       [idStr release];
       [name release];
       [link release];
       [super dealloc];
    }
    

    Normally you would copy the object in the init, this is a better way then since the orginal object can then savely be edited or released.

    -(id)initWithVideoItem:(VideoItem*)video{
        if ((self = [super init])) {
            name = [video.name copy];
            link = [video.link copy];
            idStr = [video.idStr copy];
        }
        return self;
    }
    

    Since the copy method return a retained object you want to skip the property, since that would increase the retain count.

    On a other note: the objective-c convention the private ivar should start with an _ to make it more obvious that they are not properties.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this class header //header for class. #ifndef Container_H #define Container_H #include <iostream>
For example, i have this: class BasePacket { int header; int type; } class
I have this code inside a header (edited): template <int i> class A {};
I have a header which I constructed like this: <header class=top> <a href=> <span
i have this header at the top: http://yoursdproperty.com/ how do i move the swf
I have this header file, zeeheader.h, and I wrote some classes in it, I'm
I have a header file. In this header I want to use a map
I have a header file like this: #ifndef __GEN_NOTE_MARKERS_TO_DEVELOPERS_HPP__ #define __GEN_NOTE_MARKERS_TO_DEVELOPERS_HPP__ #ifdef _DEBUG //
I have defined a format like this: # header format format STDOUT_TOP = pid
In reference with this question We have a header with a date picked component

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.