Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation errors #3

Open
jweyrich opened this issue Aug 7, 2012 · 1 comment
Open

Compilation errors #3

jweyrich opened this issue Aug 7, 2012 · 1 comment

Comments

@jweyrich
Copy link

jweyrich commented Aug 7, 2012

Apart from what @florentmorin already fixed in his pull request, I still get the following errors during compilation:

  1. No known class method for selector 'tableCellEditableTextColor'
  2. Implicit declaration of function 'STLocalizedString' is invalid in C99
  3. No visible @interface for 'NSString' declares the selector 'isEmailAddress'
  4. Use of undeclared identifier 'STDefaultNavBarHeight'

I also couldn't find where these are defined. Doing a grep -rn "tableCellEditableTextColor" * returns only the line where it's used. The same applies to others.

Please, would you mind checking if you didn't miss a file during your commits?

FWIW, I generally enable some compiler warnings, and it revealed some warnings regarding implicit conversions and signedness comparisons. If you're willing to take a look, I can push my changes and send you a pull request.
I also introduced some macros to make ARC projects import your code and build seamlessly.

Thank you.

@jtoce
Copy link

jtoce commented Feb 28, 2013

I get the same compilation errors. First thing I did since I'm using ARC is going into the project settings > Build Phases > Compile Sources and then set the compiler flag to "-fno-objc-arc" for all of the files.

I just hacked a workaround by adding the following to my pch file:

// Patch STUtils
#import "UIView+STUtils.h"
#import "NSString+STUtils.h"
#import "UIColor+STUtils.h"
#import "Base64.h"
#include <CommonCrypto/CommonDigest.h>
#define STLocalizedString(key) NSLocalizedString(key, nil)
#define STDefaultNavBarHeight 44.0f

I got Base64.h from GitHub: https://github.com/nicklockwood/Base64

The other 3 category extensions I just wrote:

@implementation UIView (STUtils)

- (CGRect)centeredSubRectOfSize:(CGSize)size insideRect:(CGRect)rect {
    CGFloat originX = 0;
    CGFloat originY = 0;
    CGFloat sizeHeight = 0;
    CGFloat sizeWidth = 0;

    // Force the sub rect to be no larger than rect
    if (size.width >= rect.size.width) {
        sizeWidth = rect.size.width;
        originX = rect.origin.x;
    } else {
        sizeWidth = size.width;
        originX =  rect.origin.x + (rect.size.width-size.width)/2.0f;
    }
    if (size.height >= rect.size.height) {
        sizeHeight = rect.size.height;
        originY = rect.origin.y;
    } else {
        sizeHeight = size.height;
        originY =  rect.origin.y + (rect.size.height-size.height)/2.0f;
    }
    return CGRectMake(originX, originY, sizeWidth, sizeHeight);
}

@end

@implementation NSString (STUtils)

- (BOOL)isEmailAddress {
    // This regular expression is adapted from a version at http://www.regular-expressions.info/email.html
    // and is a complete verification of RFC 2822.
    NSString *emailRegEx =
    @"(?:[a-z0-9!#$%\\&'*+/=?\\^_`{|}~-]+(?:\\.[a-z0-9!#$%\\&'*+/=?\\^_`{|}"
    @"~-]+)*|\"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\"
    @"x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*\")@(?:(?:[a-z0-9](?:[a-"
    @"z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\\[(?:(?:25[0-5"
    @"]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-"
    @"9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21"
    @"-\\x5a\\x53-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)\\])";

    NSPredicate *regExPredicate =
    [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegEx];
    return [regExPredicate evaluateWithObject:self];
}

@end

@implementation UIColor (STUtils)

+ (UIColor *)tableCellEditableTextColor {
    // Set to your color of choice
    return [UIColor greenColor];
}

@end

It's not pretty but it works well enough. The only remaining issues are semantic or deprecations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants