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 6857339
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:00:19+00:00 2026-05-27T02:00:19+00:00

I am new to ARC, and I have an object which has some internal

  • 0

I am new to ARC, and I have an object which has some internal classes as members. On the init method I want to allocate new objects for them.

ClassA.h

#import "ClassB.h"
@interface ClassA : NSObject
@property (assign) ClassB *member;
@end

ClassB.h

@interface ClassB : NSObject
@property (assign) NSString *name;
@end

ClassA.m

@synthesize member = _member;
-(id)init
{
    _member = [[ClassB alloc] init];
}

But I get “Assigning retained object to unsafe property” errors. I searched over the inter webs, and see no other information on this specific warning. It compiles, but gets a runtime bad access exception.

  • 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-05-27T02:00:20+00:00Added an answer on May 27, 2026 at 2:00 am

    The immediate problem is that you’re assigning the object to a member marked weak, which means that the object won’t have a strong reference and will be deallocated immediately. Using strong or retain instead of weak or assign will fix that.

    A larger problem with your -init method is that it doesn’t call [super init], and it doesn’t return anything. At minimum, your -init should look like this:

    -(id)init
    {
        self = [super init];
        if (self != nil) {
            self.member = [[ClassB alloc] init];
        }
        return self;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to ARC. I want to call a method in a complete block,
I have an NSOperation subclass which uses Core Data. It has a custom init
In one of my classes I have an -(id) init method. The first thing
I have a base class line which has a child class arc (note that
I have two classes an Arc class and a Line class public class Arc
i have a rotated arc drawn using android 2d graphics c.drawArc(new RectF(50, 50, 250,
I have an iOS app that I want to convert to using ARC .
New to Mongo, taking on the analytics quest and have a schema question. I'm
New class is a subclass of the original object It needs to be php4
I have an NSTimer object that I need to repeatedly execute. The code that

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.