Affichage des articles dont le libellé est Active questions tagged objective-c - Stack Overflow. Afficher tous les articles
Affichage des articles dont le libellé est Active questions tagged objective-c - Stack Overflow. Afficher tous les articles

vendredi 8 mai 2015

Xcode lldb not storing properties

I am currently using Xcode 6.3.1. In the debug area, I pause the app and store a property like p NSString * $test = @"word" in the debug window. If I type po $test the output would be word, this is perfect but as soon as I let the app run. When I pause it again out of scope of the class/method it seems that they property is nil. When I type p $test my output would be (NSString *) $test =.

Is this a bug with this version of Xcode or can it be fixed?

Thanks

How to check the validation of edit text for pan card in objective c?

I have to validate the test is a valid pan card with help of some regular expression.can any one help this out.

I found a good solution in java and check out the below stack
How to check the validation of edit text for pan card?

View factory for iOS

I am trying to create a View factory for iOS and I am getting into some trouble. The view factory should be a able to create multiple UIImageViews, MKMapViews or UIWebViews and add them to a view vertically. I have a problem with the web view cause I have to wait for webViewDidFinishLoad. If the methods are implemented in the ViewController which implements the UIWebViewDelegate and the delegate of the webviews is set to the controller everything works fine. The thing is that I want to put all of this in a separate class but the webViewDidFinishLoad is never been called. Is there a way to achieve that? Tell me if you need any code

Code: Part is added

- (void)addPart
{
  if (self.viewPartStrings.count != 0) {
    NSString *viewPartString = [self.viewPartStrings objectAtIndex:0];
    NSString *viewPartIdentifier = [self getViewPartIdentifier:viewPartString];
    NSString *viewPartDefinition = [self getViewPartDefinition:viewPartString];
    if ([viewPartIdentifier isEqualToString:kWeb]) {
        [self createTextWebViewPart:viewPartIdentifier];
    } else if ([viewPartIdentifier isEqualToString:kMap]) {
        [self createMapViewPart:viewPartDefinition];
    } else if ([viewPartIdentifier isEqualToString:kImage]) {
        [self createImageViewPart:viewPartDefinition];
    }
  }
}

Views are created:

- (void)createTextWebViewPart:(NSString *)viewPartText
{
    WebViewPart *webViewPart = [[WebViewPart alloc]initWithFrame:[self getViewPartFrameForHeight:0]];
    [webViewPart createViewForText:viewPartText];
    [webViewPart setDelegate:self];
}

- (void)createImageViewPart:(NSString *)viewPartDefinition
{
    //create image
}

- (void)createMapViewPart:(NSString *)viewPartDefinition
{
    //create map
}

But here is the point. This method is never called. Not if the class extends NSObject and not if the class extends UIView:

- (void)webViewDidFinishLoad:(UIWebView *)webView
{
    CGRect frame = webView.frame;
    frame.size.height = 1;
    webView.frame = frame;
    CGSize fittingSize = [webView sizeThatFits:CGSizeZero];
    frame.size = fittingSize;
    [webView stringByEvaluatingJavaScriptFromString:@"document.body.style.webkitTouchCallout='none';"];
    int height = frame.size.height + 70;
    [self addToView:webView forHeight:height];

}

Kahn algorithm & reachability

For learning purpose I'm developping an application that in real life would work basically like Quartz Composer or the recent Vuo. I'm building the graph of nodes on a Core Data Framework basis.

Basically I have a Node entity with a to-many relationship with Input and Output entities (a node can have multiple inputs and multiple outputs). Input has a to-one relationship to a Connection entity, while Output has a to-many relationship with the latter (an input can have only one connection, while an output can have many).

To read the graph I'm using a Topological Sorting algorithm (Kahn's one), described here. The code is as follows :

/**
 * Get all nodes.
 */
NSFetchRequest *request = [NSFetchRequest fetchRequestWithEntityName:@"Node"];
NSMutableArray *nodes = [[[_document managedObjectContext] executeFetchRequest:request error:nil] mutableCopy];
/**
 * Reset the nodes 'visited' flag.
 */
[self reset:nodes];
/**
 * Get sources: predicate for nodes without input ports or with input ports without connections.
 */
[request setPredicate:[NSPredicate predicateWithFormat:@"inputs == nil OR ALL inputs.connection == nil"]];
NSMutableArray *sources = [[[_document managedObjectContext] executeFetchRequest:request error:nil] mutableCopy];
/**
 * Perform a topological sort.
 */
while ([sources count] > 0) {
    /**
     * While there are sources.
     */
    NSManagedObject *node = [sources lastObject];
    /**
     * Add the node to the tail of the final graph (NSMutableArray).
     */
    [_graph addObject:node];
    [sources removeLastObject];
    /**
     * Outputs.
     */
    NSMutableSet *outputs = [node valueForKey:@"outputs"];
    for (NSManagedObject *output in outputs) {
        /**
         * Get output connections.
         */
        NSMutableSet *connections = [output valueForKey:@"connections"];
        for (NSManagedObject *connection in connections) {
            /**
             * Set the connection as already visited.
             */
            [connection setValue:@(YES) forKey:@"kConnectionVisited"];
            NSManagedObject *n = [[connection valueForKey:@"destination"] valueForKey:@"node"];
            /**
             * Set the 'source' flag to YES by default.
             */
            BOOL isNewSource = YES;
            /**
             * Get connected inputs.
             */
            NSMutableSet *inputs = [n valueForKey:@"inputs"];
            for (NSManagedObject *input in inputs) {
                /**
                 * Check if one of the input connections was visited.
                 * If not, then we need to process this connection and
                 * don't add it to sources for next pass.
                 */
                if ([[[input valueForKey:@"connection"] valueForKey:@"kConnectionVisited"] isEqualTo:@(NO)]) {
                    isNewSource = NO;
                    break;
                }
            }

            if (isNewSource) {
                [sources addObject:n];
            }
        }
    }
}
/**
 * Set the execution index for display.
 */
for (int i; i < [_graph count]; i++) {
    [[_graph objectAtIndex:i] setValue:@(i) forKey:@"kNodeExecutionIndex"];
}

I'm trying to understand the logic of how (and where in this code) I'd have to compute reachability for each Node (therefore for each Input) entity, if it is possible.

My questions are :

  • Is it possible to compute the reachability of nodes inside the Kahn's algorithm ?
  • If appropriate, where and how to do it, so I can understand why it is working ?

Thank you.

XCode compile variables

I am developing a chat application. I am using Quickblox as backend as service. I have created 3 projects (each one different mode) on the admin panel : development, staging and production. Each mode has its specific properties. I want each mode to be activated as follows :

  • Development : debug.
  • Staging : client release.
  • Production : app store deployment.

How can i achieve that automatically (via XCode) without having to change my global variables values depending on the mode ?

How Access instance Variable in Class method

I am a new iOS developer, i try to access instance variable in class method but i can't access.please give me some solution here is my code

h.file

@protocol ServiceProvideDelegate <NSObject>
@required
-(void)responeFromURL:(NSDictionary*)dicResponse;
@end

@interface AFNetworkServiceProvider : NSObject
{
   id <ServiceProvideDelegate> delegate;
}
@property (nonatomic,strong) id delegate;

+(NSDictionary*)getResponseFromURL:(NSURL*)url;
@end

m.file

@implementation AFNetworkServiceProvider
@synthesize delegate;
+(void)getResponseFromURL:(NSURL *)url
{
 @try
 {
    NSURLRequest *request=[NSURLRequest requestWithURL:url];
    AFHTTPRequestOperation *requestOperation=[[AFHTTPRequestOperation alloc]initWithRequest:request];
    requestOperation.responseSerializer=[AFJSONResponseSerializer serializer];

    [requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject)
    {
        if(delegate)
        {
          [delegate responeFromURL:responseObject]
       } 
    }
    failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        NSLog(@"Response Error :- %@",[error localizedDescription] );
    }];
    [requestOperation start];    
}
@catch (NSException *exception)
{

}
@finally {

}
}

Try to Returne Response object using protocol method, but i get the error at if(delegate) unable to access instance variable in class method

How to customize iOS UINavigationItem?

I suppose that this is duplicate, but after a research I can not understand how to customise UINavigationItem.

I have custom ViewController (VC) which implements custom class SWRevealViewController (I need to create sliding menu). I have Menu VC and for each element of the menu I have Navigation VC with custom VC for each element of the menu.

To work each back button must be defined in Designer and to have outlet (I also added outlet for navigation item):

@property (weak, nonatomic) IBOutlet UIBarButtonItem *btnSidebareMenu;
@property (weak, nonatomic) IBOutlet UINavigationItem *niTitle;

In my .m file I have this code:

self.navigationItem.title = @"Custom title";

self.navigationController.topViewController.navigationItem.leftBarButtonItem = self.btnSidebareMenu;
self.btnSidebareMenu.enabled=TRUE;
self.btnSidebareMenu.style=UIBarButtonSystemItemRefresh;

to customise button and title for each Menu element VC.

I use this code to manage navigation to menu:

// Manage menu button
SWRevealViewController *revealViewController = self.revealViewController;
if ( revealViewController )
{
    [self.btnSidebareMenu setTarget: self.revealViewController];
    [self.btnSidebareMenu setAction: @selector( revealToggle: )];
    [self.view addGestureRecognizer:self.revealViewController.panGestureRecognizer];
}

The navigation is ok, but I can not customise appearance of my Navigation bar:

I receive this:

enter image description here

, but I need something like this:

enter image description here

Any recommendations how to do that?

EDIT:

Ok, I managed to show proper size image, to change colour of the navigation bar, but I can not issue with status bar and navigation bar. When I set background colour of the navigation bar it fills also status bar. I see different solutions but they don't work or I don't understand them.

REMARK: I have several pages which are not part of Navigation controller in which my status bar is white. I need this also be the case for all my pages. (I need them to look like image 2, on which status bar is white and navigation section is blue).

Detect Unwind Event in Parent without Child Using Delegate

It is standard practice to use a parent delegate in a child view controller when performing segues, but I recently learned about the Law of Demeter from NSHipster and thought it would be ideal for the parent to know that its viewWillAppear was the result of returning from the child view controller. The child wouldn't have to know anything about or need to tell the parent anything.

Is there an elegant way to handle this?

Increasing height of UITableView when user drags button up

I have a UIView that takes up bottom half of the screen. It has a row of buttons on the top and then a UITableView that takes up the rest of the UIView. I want users to be able to click the button labeled "drag me" and be able to pull the UIView up to cover as much of the top half of the screen as they want.

More info on layout of UITableView and the UIView that contains it.

  • The UIView and the and UITableView are positioned using Auto Layout.
  • The UIView is pinned to a small UIView at bottom of screen.
  • The UITableView is pinned to the bottom of the UIView that contains it

I have successfully gotten the drag to increase or decrease size of UIView. By doing this it also moves the position of everything that it contains (ie top row of buttons and UITableView). I did by changing its frame (although originally positioned using Auto Layout) according to the translation of the y coordinate of the drag:

containerView.frame = CGRectMake(containerView.frame.minX, containerView.frame.minY + translation.y, containerView.frame.width, containerView.frame.height - translation.y)

However, I am unable to do that with UITableView. I have also tried creating a height constraint and changing that but that is also not working. This is what I have tried):

var constH:NSLayoutConstraint?

//in viewDidLoad        
constH = NSLayoutConstraint(item: tableView, attribute: NSLayoutAttribute.Height, relatedBy: NSLayoutRelation.Equal, toItem: nil, attribute: NSLayoutAttribute.NotAnAttribute, multiplier: 1, constant: tableView.frame.height)
tableView.addConstraint(constH!)


//in drag function
constH = NSLayoutConstraint(item: tableView, attribute: NSLayoutAttribute.Height, relatedBy: NSLayoutRelation.Equal, toItem: nil, attribute: NSLayoutAttribute.NotAnAttribute, multiplier: 1, constant: tableView.frame.height - translation.y)

I know the code is right for adding a constraint because I can put a constant there and it works (e.g. 50 changes it to that height).

The entire drag function is below:

func wasDragged(gesture: UIPanGestureRecognizer) {



    var yFromCenter: CGFloat = 0
    let translation = gesture.translationInView(self.view)
    var drag = gesture.view!
    var scale = min(200 / abs(yFromCenter), 1)
    yFromCenter += translation.y



    var yLimitTest = containerView.frame.minY + translation.y
    if yLimitTest < minimumY {

        drag.center = CGPoint(x: drag.center.x, y: drag.center.y + translation.y)
        gesture.setTranslation(CGPointZero, inView: self.view)
        drag.transform = CGAffineTransformScale(self.view.transform, scale, scale)

        //this IS working 
        containerView.frame = CGRectMake(containerView.frame.minX, containerView.frame.minY + translation.y, containerView.frame.width, containerView.frame.height - translation.y)

        //this doesn't work
        constH = NSLayoutConstraint(item: tableView, attribute: NSLayoutAttribute.Height, relatedBy: NSLayoutRelation.Equal, toItem: nil, attribute: NSLayoutAttribute.NotAnAttribute, multiplier: 1, constant: tableView.frame.height - translation.y)


        //this also doesn't work (but does for UIView containing the UITableView
        self.tableView.frame = CGRectMake(tableView.frame.minX, tableView.frame.minY + translation.y, tableView.frame.width, tableView.frame.height - translation.y)

    }
}

Constraints set but views not placed correctly

I'm having an issue with constraints. I set constraints on my UI elements that you can see below. For each I set x, y, and height/width for some. When I click "Update the Frames", everything is ok and the views are placed at the right place. But on the Preview (right window on the screenshot) and in the simulator, the views are not placed correctly and there is nothing on the screen. When I launch the app on the simulator, I have no warning in the debug console saying that there are constraints conflicts. Same in Xcode, no warning and no error.

Here are my View controller and the set constraints. You can see on the right, the preview for several devices.

xcode screenshot

Saving and Loading an NSMutableArray

I want my app to work so that when a user presses a "save" button, an NSMutableArray of strings (the array is called "names") inputted from a textfield will be saved. Naturally I also then want to be able to load the NSMutableArray any time I close/reopen the app.

Right now my save button is an IBAction "save". So in my implementation file I have:

- (IBAction)save:(id)sender
{ 
    NSArray *paths =  NSSearchPathforDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *docDir = [paths objectAtIndex:0]; 
    NSString *fileName = [NSString stringWithFormat:@"%@/myArray", docDir]; 
    [NSKeyedArchiver archiveRootObject:names toFile:fileName];
}

First of all, does this seem like it should work? Because multiple times my app crashed when I tried to then press the save button. Second am I right to be creating the file path in the IBAction? Or should I be creating it somewhere else (e.g. under viewDidLoad)?

Second, how and where should I be loading my saved NSMutableArray ("names")?

Many thanks!

Cant write data to plist file in - objective c

I'm trying to read and write data to my plist file, While the reading part goes well, the writing part does nothing.

I might be mistaken for the writing part - i can't see any changes in my file under my bundle - it is still empty after my changes, and when i close the app and open it again - i still see empty email address line.

The code for writing (and placing the plist in the document folder for future writings)

NSFileManager *fileManger=[NSFileManager defaultManager];
NSError *error;
NSArray *pathsArray = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES);
NSString *doumentDirectoryPath=[pathsArray objectAtIndex:0];
NSString *destinationPath= [doumentDirectoryPath stringByAppendingPathComponent:@"userData.plist"];

NSLog(@"plist path %@",destinationPath);
if ([fileManger fileExistsAtPath:destinationPath]){
    NSLog(@"database localtion %@",destinationPath);
    //return;
}

NSString *sourcePath = [[[NSBundle mainBundle] resourcePath]stringByAppendingPathComponent:@"userData.plist"];
[fileManger copyItemAtPath:sourcePath toPath:destinationPath error:&error];
NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile: sourcePath];
NSString *emailAddress = (NSString *)[dict objectForKey: @"emailAddress"];
if([emailAddress isEqualToString:@""])
{
    // Do stuff
}

And for writing

NSArray *pathsArray = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES);

NSString *doumentDirectoryPath =[pathsArray objectAtIndex:0];

NSString *destinationPath = [doumentDirectoryPath stringByAppendingPathComponent:@"userData.plist"];

NSMutableDictionary *plistDict = [[NSMutableDictionary alloc] initWithContentsOfFile: destinationPath];

[plistDict setValue:@"myEmail@gmail.com" forKey:@"emailAddress"];
[plistDict writeToFile:destinationPath atomically: YES];

But as i said, nothing is changed in the file itself, and not even when i save, close the app and open it again (the string is always empty on my reading part)

Any help will be more than welcomed.

How do i draw a UIView to a CGContext without renderInContext when it is not attached to any hierarchy

I am drawing stuff onto a video frame and the best way i found is to get the CVImageBufferRef from the Video frame and then draw into/onto it like with any other CGContext drawing.

Now i have loads of UIViews that i simply create without adding them to any superview. I want these UIViews drawn without renderInContext because this would take me 1 second per frame or 30 sec rendertime per second of video.

If i use drawViewHierarchyInRect nothing is drawn.

If i use drawRect nothing is drawn and i get lots of invalid context errors

I am calling setNeedsDisplayand setNeedsLayout before and the Rects are all valid.

Same issue with non-custom UIViews like a UILabel.

CVImageBufferRef imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer);

   // Lock the image buffer
    CVPixelBufferLockBaseAddress(imageBuffer,0);



    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
    CGContextRef context = CGBitmapContextCreate(CVPixelBufferGetBaseAddress(imageBuffer),
                                                     CVPixelBufferGetWidth(imageBuffer),
                                                     CVPixelBufferGetHeight(imageBuffer),
                                                     8,
                                                     CVPixelBufferGetBytesPerRow(imageBuffer),
                                                     colorSpace,
                                                     kCGBitmapByteOrder32Little |
                                                     kCGImageAlphaPremultipliedFirst);


    // now i want to draw my UIView


    CGContextRelease(context);
    CGColorSpaceRelease(colorSpace);



    // Unlock the image buffer
    CVPixelBufferUnlockBaseAddress(imageBuffer,0);

Changing UIImageView dynamically

imagesArray is an array of UIImageViews

for (int i = 0; i < [imagesArray count]; i++) {                
    [[imagesArray objectAtIndex:i] setImage:[UIImage imageNamed:@"set-image.png"]];
}

This will always set the last or i(th) image correctly. It will not loop and change all the images I need. Is there another way to manage this?

How can I calculate the size of a UICollectionViewCell loaded from a xib with autolayout aspect ratio constraints?

I have a UICollectionViewCell that is loaded from a xib and stored in a property to help with calculating cell sizes for my collection view. The collection view always has only one column, so the cells vary in their widths based on the phone the user has (iphone 5/6/6+). The xib has an image view with an aspect ratio that must remain constant for all phone sizes.

The problem I run into stems from this configuration. I cannot seem to make the cell size the way I want based on a fixed width. My sizeForItemAtIndexPath: method looks like this:

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
    self.sizingCell.frame.size.width = self.flowLayout.fullViewSectionSize.width;
    [self configureCell:self.sizingCell atIndexPath:indexPath];
    [self.sizingCell setNeedsLayout];
    [self.sizingCell layoutIfNeeded];
    CGSize size = [self.sizingCell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize];
    return size;
}

I'm doing what I've read I'm supposed to for dynamic size calculations with an off-screen cell, but the problem is that when layoutIfNeeded is called, I get an unsatisfiable constraint exception with my constraints and an extra constraint that sets the height of the cell to be the height of it as defined in the xib. The system never breaks this extra height constraint I did not add, so the height of the cell is always this incorrect height of the view at design time in the xib.

Can I somehow remove this extraneous constraint that causes this to not work? Is there some other setting to set here that does what I need? I've tried turning off translatesAutoResizingMaskIntoConstraints to no avail as well. How can I make a xib-loaded cell figure out it's size based on constraints involving aspect ratios?

iOS: How do I draw a line (UIBezierpath or otherwise) that fades over time, and interacts with views as it touches them?

For example:

I draw the orange line below with my finger, as it touches the blue squares, they light up.

I can draw a line using UIBezierPath from StackOverflow questions / tutorials I found, but I have no idea how to make it fade away or interact with other views.

This is not a for a game, just a regular iOS app. I'm not sure if that changes things.

Any ideas?

Example Image

Center UILabel Subview

I have a UIImageView as the background view of my table view. When there is no data for the table, I am adding a UILabel as a subview of the image view. I am having trouble getting the label centered though. The label is always off to the right.

UIImageView *backgroundImageView = [[UIImageView alloc]initWithFrame:self.tableView.frame];
    backgroundImageView.image = [UIImage imageNamed:@"background"];
    backgroundImageView.center = self.tableView.center;

    self.noLocationsLabel = [[UILabel alloc]initWithFrame:backgroundImageView.frame];
    self.noLocationsLabel.center = backgroundImageView.center;
    self.noLocationsLabel.text = @"No saved locations";
    self.noLocationsLabel.textAlignment = NSTextAlignmentCenter;
    self.noLocationsLabel.textColor = [UIColor blackColor];
    self.noLocationsLabel.font = [UIFont fontWithName:@"Chalkboard SE" size:24.0];

self.tableView.backgroundView = backgroundImageView;

if (self.locationsArray.count == 0) {
        self.navigationItem.rightBarButtonItem.enabled = NO;

        [self.tableView.backgroundView addSubview:self.noLocationsLabel];
        self.tableView.userInteractionEnabled = NO;
    }

navigationItem titleview align center between buttons

I have the code likes, in the title bar I am having 3 buttons, left search button, right camera button and option button, in between I am having title.

What I want to do is, I want to display the title centered between the search button and Camera button, can anyone help me how to do this.

//Left Button
UIBarButtonItem *leftSearch = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"btn_search"] style:UIBarButtonItemStyleBordered target:self action:@selector(gotoSearch)];

leftSearch.imageInsets = UIEdgeInsetsMake(0, -5.0f, 0, 0);

[leftSearch setTintColor:[UIColor whiteColor]];
/////////

//Right Button -- First Camera
UIBarButtonItem *rightCamera = [[UIBarButtonItem alloc]
                                initWithImage:[UIImage imageNamed:@"icon_camera"]
                                style:UIBarButtonItemStyleBordered
                                target:self
                                action:@selector(gotoPhotoGallery)];
[rightCamera setTintColor:[UIColor whiteColor]];
rightCamera.imageInsets = UIEdgeInsetsMake(0, 0, 0, -59.0f);
///////////////////

//Right second Button -- for options menu
UIBarButtonItem *rightMenu = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"header_option"] style:UIBarButtonItemStyleBordered target:self action:@selector(gotoPhotoGallery)];
[rightMenu setTintColor:[UIColor whiteColor]];
rightMenu.imageInsets = UIEdgeInsetsMake(0, 0, 0, 5.0f);
///////////////////

NSArray *buttons = @[rightMenu, rightCamera];

self.navigationItem.rightBarButtonItems = buttons;

[[self navigationItem] setLeftBarButtonItem:leftSearch];

//Title Label

UILabel *label = [[UILabel alloc] initWithFrame:CGRectZero];
label.backgroundColor = [UIColor clearColor];
label.font = [UIFont fontWithName:@"Museo Sans" size:20];
label.textAlignment = UITextAlignmentCenter;
label.textColor = [UIColor whiteColor];
label.text = LoginUserName;
self.navigationItem.titleView = label;
[label sizeToFit];

Why is this NSString null in a FireBase query block?

I can't figure out why this string is null inside the FQuery block. My app keeps crashing when I build the dailyLog MutableDictionary at the user key;

NSString *userID = [self.userProfile objectForKey:@"userID"];
self.logFirebase = [[Firebase alloc] initWithUrl:@"http://ift.tt/1zK8jF4"];
[[[self.logFirebase queryOrderedByChild:@"userID"] queryEqualToValue:userID] observeEventType:FEventTypeValue withBlock:^(FDataSnapshot *snapshot) {

    FQuery *queryRef = [[self.logFirebase queryOrderedByChild:@"date"] queryEqualToValue:[df stringFromDate:[NSDate date]]];
    [queryRef observeEventType:FEventTypeValue withBlock:^(FDataSnapshot *snapshot) {

        NSLog(@"value:%@", snapshot.value);
        if (![snapshot.value isEqual:[NSNull null]]) {
            self.dailyLog = snapshot.value;
        }else{
            self.dailyLog = [[NSMutableDictionary alloc] init];
            NSLog(@"users Profile:%@",self.userProfile); //This is working fine, I see data and I'm using the right keys

            [self.dailyLog setObject:[df stringFromDate:[NSDate date]] forKey:@"date"];
            [self.dailyLog setObject:userID forKey:@"user"];
            [self.dailyLog setObject:[NSNumber numberWithInt:450] forKey:@"calories"];


            [[self.logFirebase childByAutoId] setValue:self.userProfile];

        }

    }];

}];

EDIT: When I log self.userProfile, I get the proper info I want. But when I log the userID itself from within the FQuery block, it's null

How to authenticate IOS app without displaying Auth 2.0 VIewcontroller?

Here , i want to get 'access token' for iPhone application without displaying Auth2.0 view controller. Authenticate the app and get access token and refresh token. Help me to solve this problem. Remember I do not want to show UI of Google. Just make two field username and password . With Log in button authenticate the app and get tokens.