Q:

How to implement initWith method passing custom object as an argument?

For instance I have following class:
@interface PrivateInfo: NSObject

- (instancetype)initWithPrivateInfoObject:(PrivateInfo *)pi;

@end

@implementation PrivateInfo
{
   @private
   NSString *name;
   NSString *creditCardID;
}

- (instancetype)initWithPrivateInfoObject:(PrivateInfo *)pi
{
   // how to init current object with passed pi ?
}

- (PrivateInfo *)copy
{
  // how to create a copy of current object?
}
@end

A:

Assuming ARC:
.h:
@interface PrivateInfo: NSObject <NSCopying>

- (instancetype)initWithPrivateInfoObject:(PrivateInfo *)pi;

@end

.m:
@implementation PrivateInfo {
    NSString *name;
    NSString *creditCardID;
}

- (instancetype)initWithPrivateInfoObject:(PrivateInfo *)pi
{
    self = [super init];
    if (self) {
        name = pi->name;
        creditCardID = pi->creditCardID;
    }

    return self;
}

- (PrivateInfo *)copyWithZone:(NSZone *)zone {
    PrivateInfo *res = [[PrivateInfo alloc] initWithPrivateInfoObject:self];

    return res;
}

@end

You don't need @private in the @implementation block for declaring ivars. And use the NSCopying protocol is you want to copy objects.

