dimanche 28 juin 2015

Passing Facebook login information to the second view

This is a 2 part question.

1.) Once the user login to the application i want to navigate to DashboardViewController. However, i am ending up with a warning.

Warning: Attempt to present on whose view is not in the window hierarchy!

How to solve this?

2.) I want to pass (id<FBGraphUser>)user to the DashboardViewController, How can i achieve this?

The code is as follows:

-(void)viewWillAppear:(BOOL)animated{
    //[self toggleHiddenState:YES];
    self.lblLoginStatus.text = @"";

    self.loginButton.delegate = self;
    self.loginButton.readPermissions = @[@"public_profile", @"email"];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


#pragma mark - Private method implementation

-(void)toggleHiddenState:(BOOL)shouldHide{
    self.lblUsername.hidden = shouldHide;
    self.lblEmail.hidden = shouldHide;
    self.profilePicture.hidden = shouldHide;
}


#pragma mark - FBLoginView Delegate method implementation

-(void)loginViewShowingLoggedInUser:(FBLoginView *)loginView{



    self.lblLoginStatus.text = @"You are logged in.";

    [self toggleHiddenState:NO];
}



-(void)loginViewFetchedUserInfo:(FBLoginView *)loginView user:(id<FBGraphUser>)user{
    NSLog(@"%@", user);
    self.profilePicture.profileID = user.objectID;
    self.lblUsername.text = user.name;
    self.lblEmail.text = [user objectForKey:@"email"];
//

    [self performSelector:@selector(displayDashboard) withObject:nil afterDelay:0.5];

}

-(void)displayDashboard{
    DashboardViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"DashboardSegue"];

    [[[[[UIApplication sharedApplication] delegate] window] rootViewController] presentViewController:vc animated:YES completion:nil];
}




-(void)loginViewShowingLoggedOutUser:(FBLoginView *)loginView{
    self.lblLoginStatus.text = @"You are logged out";

    [self toggleHiddenState:YES];
}


-(void)loginView:(FBLoginView *)loginView handleError:(NSError *)error{
    NSLog(@"OKKKKK %@ ", [error localizedDescription]);

}


@end

When to use ?, !, None, or Lazy?

I just started learning Swift and recently found out about

1) "Normal" variables (for lack of a better name):

ex: var test1: String

2) "Optional" variables

ex: var test2: String?

3) "Implicitly Unwrapped Optionals"

ex: var test3: String!

4) Lazy variables

ex: lazy var test4: String

My understanding is this:

1) Use "Optional" variables (?) when the variable may or may not be initialized at points in the future starting from initialization

2) Use "Implicitly Unwrapped Optionals" (!) when the variable is guaranteed to be initialized

3) Optionals can be converted to Implicitly Unwrapped Optionals via "Forced Unwrapping"

ex: let possibleString: String? = "Hello" println(possibleString!)

4) Use Lazy variables when there is no need for something to be set until initialization (it seems these can be used with (?) or (!))

Therefore, my questions are:

1) When do I use option 1 - a variable without ? and without !

2) When do I use "lazy"

2.1) I read "lazy" is often used for singletons (http://ift.tt/1GINd7P) - why?

I have the most experience in Java and C++ terms, if that helps with my background for answering.

Xcode swift: global variable is empty

here is my code that did not work:

AppDelegate.swift

import UIKit

var systemLanguage = ""

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        // Override point for customization after application launch.

        // Systemsprache erkennen
        let systemLanguage = NSLocale.preferredLanguages()[0] as! String
        println("Device system language: \(systemLanguage)")

        return true
    }

settingsTableViewController.swift

override func viewDidLoad() {
        super.viewDidLoad()

        self.navigationController!.navigationBar.barStyle = UIBarStyle.Black
        self.navigationController!.navigationBar.tintColor = UIColor.whiteColor()

        if systemLanguage == "de" {

            self.title = "Einstellungen"

        } else {

            self.title = "Settings"

        }
        println("Device system language: \(systemLanguage)")

        self.tableView.backgroundColor = UIColor.darkGrayColor()

    }

When the app is starting the console says: Device system language: de

but when I change the view to settingsTableViewController the variable systemLanguage is empty. The console says: Device system language:

Why does it happen?

IOS optimization using time profiler and Core Animation

So I have an app, in which I use custom UIView. There are other UIView, which are subviews of that view. All of them have pan gesture recognizers, so that the user can pan them in the specific fashion. When I test my app using one such view all is well and good, it is all smooth and fps is around 55-60. However, when I add the second one(somewhat smaller then the first one, and kinda inside first one, but not as a subview). The FPS of the outer views drops to 20-30, while the inner one(which is smaller) works in 60 fps. This two views are ABSOLUTELY independent, meaning that interacting with one doesn't affect the other one. In addition to that, I checked running time on the interval of one second, the results are the following: For 1 view: 153ms For 2 views 145ms For 3 views 150ms

The calculations that are performed on each view are ABSOLUTELY identical in complexity. Why does one work smoothly, but when I add the second one it starts to lag, while the execution time stays the same ? I would appreciate if somebody could hint me at how I should debug it.

The most consuming operation according to the Time Profiler is repositioning one of the views:

view.center = newCenter

I simply can't understand why FPS drops 2-3 times, while the running time stays the same. What should I look for ?

UPDATE:

So I found the source of the problem, when one view is inside the frame of the other the whole thing is being constantly redrawn, even though no changes were made to the layout of the inner view. So when I positioned a few of them in different parts of the screen everything was fine, but when I put one "inside" the other things get messed up. Inner one works quickly, while the outer one lags. "Flash updated regions" flag in core animation show that when I interact with outer view, inner view gets updated as well. Any suggestions on what I might need to do, because I need that layout when they are one inside each other.

Thank You.

How do I cancel my IOS application last update in app store, as I found some issue with it

How do I go back to my last app version, and cancel new update?

I have just release new version of my IOS application last week but I found some bug , which wasn't there in last version. So I want to cancel new version and stop it showing in app store in update section. How do I delete in iTune connect?? Is there any way of doing this please?

Glkit gl_points only one Point is big

I have to draw many Points an the get drawn as well but only one point is big(I see the other points but they are very small).

In my vertex shader i said :gl_pointsize = 25.0;

My Glkview:

- (void)glkView:(GLKView *)view drawInRect:(CGRect)rect{

glClearColor(0.65f, 0.65f, 0.65f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glBindVertexArrayOES(_vertexArray);

// Render the object with GLKit
[self.effect prepareToDraw];

glDrawArrays(GL_POINTS, 0, 36);



// Render the object again with ES2
glUseProgram(_program);

glUniformMatrix4fv(uniforms[UNIFORM_MODELVIEWPROJECTION_MATRIX], 1, 0, _modelViewProjectionMatrix.m);
glUniformMatrix3fv(uniforms[UNIFORM_NORMAL_MATRIX], 1, 0, _normalMatrix.m);

glDrawArrays(GL_POINTS, 0, 36);

Thanks in advance

Is there a perfect way to use iOS Framework template instead of static library now?

Since iOS8 and Xcode6 has release for a year, I have still cannot find a canonical tutorial for using Framwork template (iOS Universal Framework Mk 8) to develope a static library.

enter image description here

Even though the most popular Repo I think, kstenerud/iOS-Universal-Framework, has shut down when iOS8 Framework release.

enter image description here


However, when I try to develope a Static Framework I got ton of issues to resolve:

  1. I still have to do lipo for x86_64, i386, arm64, amrv7;
  2. remove Code signature from Framework;
  3. Build a resource bundle and import it to app project independent;
  4. Framework Info.plist and modules seem useless;
  5. Still a little worried if Apple will refuse my app since use a Static Framework.

Is there a good tutorial for building and using Static Framework? Any help will be appreciated! Thx.