-1

I'm a noob to iphone development and i'm having a weird issue while trying to implement Glass Buttons (found here). My build fails because I'm getting an "unexpected @ in program error" inside the MOGlassButtons.m file. I haven't been able to find anything regarding how to resolve this issue. Any help is greatly appreciated.

MOGlassButton.m

self.gradientLayer1.colors = @[(id)[MO_RGBACOLOR(255, 255, 255, 0.45) CGColor], (id)[MO_RGBACOLOR(255, 235, 255, 0.1) CGColor]]; //<--"unexpected @ in program error" 

self.gradientLayer2.colors = @[(id)[MO_RGBACOLOR(205, 205, 205, 0) CGColor], (id)[MO_RGBACOLOR(235, 215, 215, 0.2) CGColor]]; //<--"unexpected @ in program error" 

EDIT

#import "MOGlassButton.h"

// Courtesy of https://github.com/facebook/three20
#ifndef MO_RGBCOLOR
#define MO_RGBCOLOR(r,g,b) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:1]
#endif
#ifndef MO_RGBCOLOR1
#define MO_RGBCOLOR1(c) [UIColor colorWithRed:c/255.0 green:c/255.0 blue:c/255.0 alpha:1]
#endif
#ifndef MO_RGBACOLOR
#define MO_RGBACOLOR(r,g,b,a) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:a]
#endif
B. Money
  • 931
  • 2
  • 19
  • 56

1 Answers1

1

Your problem is probably the outdated version of Xcode you are running. Your code uses Objective-C literals (the @[…] part) which are supported since Xcode 4.4 and thus not valid in earlier releases. (see What are the details of "Objective-C Literals" mentioned in the Xcode 4.4 release notes?)

Upgrading should fix your problem.

Edit

Alternatively, although I heavily recommend updating, you could use the following.

[NSArray arrayWithObjects: (id)[MO_RGBACOLOR(255, 255, 255, 0.45) CGColor], (id)[MO_RGBACOLOR(255, 235, 255, 0.1) CGColor], nil];
Community
  • 1
  • 1