2013年5月24日星期五

Unity Pro trial watermark still shows after Upgrading to Pro

I have been using the Unity 4 Pro trial version for a couple weeks now. I decided to upgrade to the actual Pro version so I could publish games.


The issue I am having is that even though I have upgraded the version away from trial, (yes, I have put the new serial number in that I was given by Unity and activated it) my games still have the Trial watermark in the bottom right corner.


Any ideas?





Twitter OAuth 1 POST requests not working

I am creating an application for iOS and I am using OAuth 1. GET requests seem to work fine but as soon as I try to make POST requests I get the following error :



[code 32] Could not authenticate you.



Now I am not quite sure what is happening, as POST requests are generated pretty similarly to the GET requests. Any ideas what is causing this error ?


Here is the code generating the request:



+ (NSURLRequest *)preparedRequestForPath:(NSString *)path
parameters:(NSDictionary *)queryParameters
HTTPmethod:(NSString *)HTTPmethod
oauthToken:(NSString *)oauth_token
oauthSecret:(NSString *)oauth_token_secret
{
if (!HTTPmethod
|| !oauth_token) return nil;



NSMutableDictionary *allParameters = [self standardOauthParameters];
allParameters[@"oauth_token"] = oauth_token;
if (queryParameters) [allParameters addEntriesFromDictionary:queryParameters];

NSString *parametersString = CHQueryStringFromParametersWithEncoding(allParameters, NSUTF8StringEncoding);

NSString *request_url = API_URL;
if (path) request_url = [request_url stringByAppendingString:path];
NSString *oauth_consumer_secret = CONSUMER_SECRET;
NSString *baseString = [HTTPmethod stringByAppendingFormat:@"&%@&%@", request_url.utf8AndURLEncode, parametersString.utf8AndURLEncode];
NSString *secretString = [oauth_consumer_secret.utf8AndURLEncode stringByAppendingFormat:@"&%@", oauth_token_secret.utf8AndURLEncode];
NSString *oauth_signature = [self.class signClearText:baseString withSecret:secretString];
allParameters[@"oauth_signature"] = oauth_signature;

NSString *queryString;
if (queryParameters) queryString = CHQueryStringFromParametersWithEncoding(queryParameters, NSUTF8StringEncoding);
if (queryString) request_url = [request_url stringByAppendingFormat:@"?%@", queryString];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:request_url]];
request.HTTPMethod = HTTPmethod;

NSMutableArray *parameterPairs = [NSMutableArray array];
[allParameters removeObjectsForKeys:queryParameters.allKeys];
for (NSString *name in allParameters) {
NSString *aPair = [name stringByAppendingFormat:@"=\"%@\"", [allParameters[name] utf8AndURLEncode]];
[parameterPairs addObject:aPair];
}
NSString *oAuthHeader = [@"OAuth " stringByAppendingFormat:@"%@", [parameterPairs componentsJoinedByString:@", "]];
[request setValue:oAuthHeader forHTTPHeaderField:@"Authorization"];

if ([HTTPmethod isEqualToString:@"POST"]
&& queryParameters != nil) {
NSData *body = [queryString dataUsingEncoding:NSUTF8StringEncoding];
[request setHTTPBody:body];
}

return request;
}


EDIT


The very last lines of the code where I set the HTTP body seem to cause the problem. When I remove the lines



NSData *body = [queryString dataUsingEncoding:NSUTF8StringEncoding];
[request setHTTPBody:body];


everything works fine, except when the parameters are exceptionally bigger like sending a base64 encoded image, where it obviously fails... What could I possibly do to fix this ?





ios facebook login - Could not connect to the server

I use default Hello Facebook Sample.


Hello Facebook Sample project is default, without any changes.


I run app, and when I try to login in Facebook, I get error:



> FBLoginView encountered an error=Error Domain=com.facebook.sdk Code=5
> "The operation couldn’t be completed. (com.facebook.sdk error 5.)"
> UserInfo=0x1ed594f0 {com.facebook.sdk:ErrorInnerErrorKey=Error
> Domain=NSURLErrorDomain Code=-1004 "Could not connect to the server."
> UserInfo=0x1ed4b690
> {NSErrorFailingURLStringKey=https://graph.facebook.com/me?sdk=ios&migration_bundle=fbsdk%3A20130409&format=json&access_token=BAAFDDRlIT2wBAGKjngoxZCh3nkTWrfQjvO6ZASvctCGIyEg1h4gUA7n4zIIwd9iYZAWrRLkxEpVZB5SjHasSGbFll8aQGi42DGSxmjjvUxpbORWKNuYTaJwWSETLUSmmR6gZCG2FVFdJqorFbWZBxJwewfVpM1Ns4XwisSz4qQwdjKuWKaZATuOnzaYnyhWYMyp71zSMkXbUa8WGBLTovti5aWTZBckDlNZCTEtT5GKhie6eSgMEbjYDs,
> NSErrorFailingURLKey=https://graph.facebook.com/me?sdk=ios&migration_bundle=fbsdk%3A20130409&format=json&access_token=BAAFDDRlIT2wBAGKjngoxZCh3nkTWrfQjvO6ZASvctCGIyEg1h4gUA7n4zIIwd9iYZAWrRLkxEpVZB5SjHasSGbFll8aQGi42DGSxmjjvUxpbORWKNuYTaJwWSETLUSmmR6gZCG2FVFdJqorFbWZBxJwewfVpM1Ns4XwisSz4qQwdjKuWKaZATuOnzaYnyhWYMyp71zSMkXbUa8WGBLTovti5aWTZBckDlNZCTEtT5GKhie6eSgMEbjYDs,
> NSLocalizedDescription=Could not connect to the server.,
> NSUnderlyingError=0x1ed57120 "Could not connect to the server."},
> com.facebook.sdk:HTTPStatusCode=200,
> com.facebook.sdk:ErrorSessionKey=<FBSession: 0x1ede3c90, state:
> FBSessionStateOpen, loginHandler: 0x1ede3070, appID: 355198514515820,
> urlSchemeSuffix: ,
> tokenCachingStrategy:<FBSessionTokenCachingStrategy: 0x1ede9990>,
> expirationDate: 2013-06-30 13:37:41 +0000, refreshDate: 2013-05-01
> 14:24:53 +0000, attemptedRefreshDate: 0001-12-30 00:00:00 +0000,
> permissions:( )>}


What is the reason of problem?


I tried to use different versions of Facebook SDK (3.5.1, 3.5, 3.2.1)


I use iPod Touch 4g with iOS 6.1


Notice: I seem this problem occurred after bug with Infinite Loop when calling requestNewPublishPermissions: in SDK 3.5 https://developers.facebook.com/bugs/188127071335876 Because when I try to login 2 weeks ago, everything was OK.





Trigger Change on UIViewController from UITableView(WEPopover)

I have a UIViewController and I am using the WEPopover controls to generate a drop-down on the view controller. The content for the WEPopover is held in a UITableViewController. The WEPopover is triggered when a UIImageView is pressed on the main UIViewController


WEPopover GitHub Link


I am aware that once a row in the table is selected the didSelectRowAtIndexPath triggers. Where I am facing a challenge is taking the result of the selected row, and then triggering a change on the main UIViewController.


What I am attempting to do is take the string in the row I have selected in the UITablewViewController, and then apply that string value (Hex String, using UIColor Extended from GitHub to convert to UIColor)as the new color overlay of the UIImageView which is located on the UIViewController





NSFetchedResultsController's delegate method handling

I have UITableView with NSFetchedResultsController attached to it. FRC's delegate methods work perfectly and everything is nice, but my cells have custom backgrounds that depend on the position of the cell: 1. on top of the UITableView (background with rounded corners on top) 2. in the middle (background with no rounded corners) 3. on the bottom (background with rounded corners on the bottom) 4. single cell (all corners are rounded). In my cell configuration method I calculate a position of the cell and I'm setting an appropriate background view to it. Everything works fine, but there is a problem in the implementation of FRC's delegate method:



- (void)controller:(NSFetchedResultsController *)controller didChangeObject:(id)anObject
atIndexPath:(NSIndexPath *)indexPath forChangeType:(NSFetchedResultsChangeType)type
newIndexPath:(NSIndexPath *)newIndexPath
{

UITableView *tableView = self.agenciesTableView;

switch(type)
{
case NSFetchedResultsChangeInsert:
{
[tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:newIndexPath]
withRowAnimation:UITableViewRowAnimationNone];
break;
}
case NSFetchedResultsChangeDelete:
{
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]
withRowAnimation:UITableViewRowAnimationNone];
break;
}
case NSFetchedResultsChangeUpdate:
{
[tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];

break;
}
case NSFetchedResultsChangeMove:
{

[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]
withRowAnimation:UITableViewRowAnimationFade];
[tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:newIndexPath]
withRowAnimation:UITableViewRowAnimationFade];
break;
}
};
}


As you can see it is completely common, but there is one issue: If the cell gets inserted to the top of UITableView, its configuration method (cellForRowAtIndexPath) gets called and it draws correctly (with rounded top corners) but the cell that is under it (that was previously on the top) remains with rounded top corners and I need to redraw it somehow.





iOS: creating a bluetooth proxy for audio streaming

Is there a way to turn an iPod/iPhone into a bluetooth proxy so that I can connect another phone to it via bluetooth and stream music through it? e.g. I have an iPod touch hooked up via USB to an iPod specific speaker system all the time and I simply connect my android phone via bluetooth to the iPod and stream music from my phone, through the iPod, to the speakers.


I want to start developing something like this, but I just found out that apple charges $100/year to do development on a real device instead of the simulator (which I can't use to test bluetooth functionality).


So far, all of the example programs I've seen have been about connecting the iPod to something else. I would like the connection to be initiated from the other device.


So, before I lose $100 trying this out, I would like to know if you all think this is feasible with the current iOS bluetooth and audio stream APIs as this would be my first foray into iOS' world of objective C.


thanks





iOS singleton shared instance and loading remote json data

This is my situation:



// data.m
@property (nonatomic, strong) NSMutableArray *jsonData;

+ (Data *)sharedData
{
static Data *sharedData;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^
{
_sharedData = [[Data alloc] init];
});

return _sharedData;
}

- (id)init
{
self = [super init];
if (self)
{
[self clear];
[self load]; // here i start loading my remote JSON data and fill self.jsonData
}

return self;
}


and I have



// main.m
[Data sharedData].jsonData; // this return nil


the jsonData return nil , i think because the request to the server is not done yet.. How can I do for wait till the remote request is done?


Thanks.


EDIT:


here's my load method



[[ApiClient sharedClient] loadDataWithSuccess:^(NSMutableArray *data)
{
self.jsonData = data;
}
fail:^(NSString *errorMessage)
{
NSLog(@"%@", errorMessage);
}];


loadDataWithSuccess returns void.