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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T20:37:57+00:00 2026-06-05T20:37:57+00:00

I am getting the above error and I’m not sure how to fix it,

  • 0

I am getting the above error and I’m not sure how to fix it, would someone be able to tell me why I am getting this error so I can fix it?

The code itself works and draws the image (except the text layer) to the screen, so I just want to remove the error. I have already searched stack overflow and found ‘casting’ but after trying this technique the error is still there.

I think it’s because I am using the methods

[CardElementsCreationClass drawHeart]

and

[CardElementsCreationClass drawValueWithSuit:suit AndValue:value]

My .m

#import "CardCreationClass.h"

@implementation CardCreationClass

//--------------------
//Create a card
//
+ (UIView *) newPlayingCardWithSuit:(NSString *)suit
                          AndValue:(NSString *)value {  
    //Create playing card UIVIew
    CGRect playingCardBounds = CGRectMake(100, 50, 100, 200);
    //CGPoint playingCardPosition = CGPointMake(100, 50);

    UIView* playingCard = [[UIView alloc] initWithFrame:playingCardBounds];

    //CREATE BACK OF CARD
    //

    //CREATE FRONT OF CARD
    CALayer* front = [CALayer layer];

    //Determine suit
    CAShapeLayer *cardSuitShapeLayer;

    if ([suit isEqualToString:@"heart"]) {
        cardSuitShapeLayer = [CardElementsCreationClass drawHeart];
    }

    [front addSublayer:cardSuitShapeLayer];

    //Determine value
    CATextLayer *cardValueTextLayer = [CardElementsCreationClass drawValueWithSuit:suit AndValue:value];

    [front addSublayer:cardValueTextLayer];

    //Add layers to card
    [playingCard.layer addSublayer:front];

    NSLog(@"Type = %@", [playingCard class]);

    //Return - **ERROR HAPPENS HERE**
    return playingCard;
}

- (id)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
    }
    return self;
}

- (void)drawRect:(CGRect)rect {
    // Drawing code
    [CardCreationClass newPlayingCardWithSuit:@"heart" AndValue:@"A"];
}

@end

Drawing code

#import "CardElementsCreationClass.h"

@implementation CardElementsCreationClass

//--------------------
//HEARTS
//
+ (CGMutablePathRef)newHeartPath {
    //Declare
    CGMutablePathRef heartPath = CGPathCreateMutable();

    //Create shape
    CGPathAddEllipseInRect(heartPath, NULL, CGRectMake(0, 0, 20, 20));
    CGPathAddEllipseInRect(heartPath, NULL, CGRectMake(20, 0, 20, 20));

    CGPathMoveToPoint(heartPath, NULL, 37.5, 16.5);

    CGPathAddLineToPoint(heartPath, NULL, 37.5, 16.5);
    CGPathAddLineToPoint(heartPath, NULL, 20, 37.5);
    CGPathAddLineToPoint(heartPath, NULL, 2.5, 16.5);
    CGPathAddLineToPoint(heartPath, NULL, 20, 10);

    CGPathCloseSubpath(heartPath);

    //Return
    return heartPath;
}

+ (CGMutablePathRef)newHeartHighlightPath {
    //Declare
    CGMutablePathRef heartHighlightPath = CGPathCreateMutable();

    //Create hightlight
    CGPathAddArc(heartHighlightPath, NULL, 0, 0, 7, -(110 * M_PI) / 180, -(0 * M_PI), NO);

    CGPathAddLineToPoint(heartHighlightPath, NULL, 4, 0);

    CGPathAddCurveToPoint(heartHighlightPath, NULL, 4, -7, 0, -7, 0, -7);

    //Return
    return heartHighlightPath;
}

+ (CAShapeLayer*)drawHeart {
    CAShapeLayer* heartShapeLayer = [CAShapeLayer layer];

    //Context
    CGContextRef context = UIGraphicsGetCurrentContext();

    //Declare
    CGMutablePathRef heartPath = [self newHeartPath];

    /*CGPathAddArc(heartPath, NULL, 10, 10, 10, M_PI, 0, false); // Left hump
    CGPathAddArc(heartPath, NULL, 30, 10, 10, M_PI, 0, false); // Right hump
    CGPathAddLineToPoint(heartPath, NULL, 20, 37.5); // Pointy end

    CGPathCloseSubpath(heartPath);*/

    //Line
    CGContextSetLineWidth(context, 8.0);
    CGContextSetLineJoin(context, kCGLineJoinRound);

    //Colour shape
    CGContextSetCMYKStrokeColor(context, 0.17, 1, 1, 0.07, 1);
    CGContextSetCMYKFillColor(context, 0.07, 1, 1, 0.01, 1);

    //Draw shape
    CGContextTranslateCTM(context, 4, 4);

    CGContextAddPath(context, heartPath);
    CGContextDrawPath(context, kCGPathStroke);

    CGContextAddPath(context, heartPath);
    CGContextDrawPath(context, kCGPathFill);

    //Colour highlight
    CGContextSetCMYKFillColor(context, 0, 0, 0, 0, 0.3);

    //Left highlight
    CGMutablePathRef heartHightlightLeft = [self newHeartHighlightPath];

    //Draw highlight
    CGContextTranslateCTM(context, 10, 9);

    CGContextAddPath(context, heartHightlightLeft);
    CGContextDrawPath(context, kCGPathFill);

    //Right highlight
    CGMutablePathRef heartHightlightRight = [self newHeartHighlightPath];

    //Draw hightlight
    CGContextTranslateCTM(context, 20, 0);

    CGContextAddPath(context, heartHightlightRight);
    CGContextDrawPath(context, kCGPathFill);

    //Attach
    heartShapeLayer.path = heartPath;

    //Release
    CGPathRelease(heartPath);
    CGPathRelease(heartHightlightLeft);
    CGPathRelease(heartHightlightRight);

    //Return
    return heartShapeLayer;
}

//--------------------
//VALUES
//
+ (CATextLayer*)drawValueWithSuit:(NSString *)suit
                         AndValue:(NSString *)value {
    CATextLayer* valueTextLayer = [CATextLayer layer];

    valueTextLayer.string = value;
    valueTextLayer.borderWidth = 2.0;
    valueTextLayer.borderColor = [UIColor blackColor].CGColor;

    valueTextLayer.bounds = CGRectMake(0, 0, 50, 50);

    //Determine colour
    if ([suit isEqualToString:@"heart"] || [suit isEqualToString:@"diamond"]) {
        valueTextLayer.foregroundColor = [UIColor redColor].CGColor;
    } else if ([suit isEqualToString:@"club"] || [suit isEqualToString:@"spade"]) {
        valueTextLayer.foregroundColor = [UIColor blackColor].CGColor;
    }

    //Return
    return valueTextLayer;
}

@end
  • 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-05T20:37:59+00:00Added an answer on June 5, 2026 at 8:37 pm

    Just rename the method

    + (UIView *) newPlayingCardWithSuit:(NSString *)suit
                               AndValue:(NSString *)value
    

    To something that does not start with the word new. For example:

    + (UIView *) playingCardWithSuit:(NSString *)suit
                            andValue:(NSString *)value
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Getting the above error in following code. How to rectify it. Thanks. Please look
I'm getting the above error when I try to run the following code: int
I am getting above error what can be the possible reasons for it ?
I keep keep getting the above error when I run the code below. All
I am getting above error in some machines but not in some machines while
I'm getting the above error on the ToList() line of the code below if
I'm getting the above error using the latest KnockoutJS library using v1.3.0beta. However, this
I am getting the above error whenever I test on an emulator, but not
when i test this page http://www.catalogues4u.com.au/ViewCategory.aspx?catID=119 im getting the above error. to replicate this
i am doing this: MsgBox ActiveWorkbook.Name and getting the above mentioned error. please note

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.