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

lundi 11 mai 2015

Sharing classes between existing iPhone project and Watch Kit extension

I would like to share a class "MyClass" that I added as target to an iPhone project to which I then added a Watch Kit extension target.

Whenever I import the "MyClass" in the Watch Kit extension source code I get:

Undefined symbols for architecture arm64: "_OBJC_CLASS_$_MyClass", referenced from: objc-class-ref in WKMyInterfaceController.o ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

Any idea on how to solve this? It seems a linker problem so I guess I have to add the source code of the class MyClass to the linked libraries/headers of the WatchKit Extension app but I am not sure if there is a better way to do it.

Parse a XML file in a specified format iOS

Is there anyway through through which I can parse this XML file that is in this following format:-

<?xml version="1.0" encoding="utf-8"?>
<CountryList>
  <Country CountryId="AF">Afghanistan</Country>
  <Country CountryId="AX">Akrotiri</Country>
  <Country CountryId="AL">Albania</Country>
...........................................
...........................................

I need the Country ID and the name:- i.e "AL" and "Albania" , So, is it possible to parse specified XML, and store Country Id and country name in an Array. Any suggestion will be helpful.

I need to find the data from lynda dot com app on iphone 6

Where does iPhone 6 stores the application data from lynda.com app? can someone please help. I tried looking under /applications but it is not there. By the way i am using Ifile

Thanks for your help!

How to create an image view for image when image is added to imageview

the attached screenshot is the description of my problem. i have a problem to add multiple images to image view.

enter image description here

how to create dropdown with "Other" option in ios

i am using objective c with xcode 6. i want to create a drop down where user can select the source who told him about my app.

options are "Tv","Facebook","Google","Print Media","other".

if he selects other he should be able to write the other source.

can any body help?

compiler error in using Zbar SDK(library) in xcode 6

1 I got the following error while building my project.

Undefined symbols for architecture i386: "_OBJC_CLASS_$_ZBarCaptureReader", referenced from: objc-class-ref in ZBarViewController.o ld: symbol(s) not found for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation) .I have try all kinds of solution form google but unable to solve it . Help will be appreciated Thanks Screen Shot Attached

watch kit showing the updated data from the server

The scenario is.

1) I have already existing iOS app for iPhone device. The application is showing the real time data in dashboard page. The data on Dashboard is updated after every 60 sec by calling the web services from iOS app.

2) I want to develop the apple watch application based on same iPhone app Which will show the dashboard with data updating after every 60 seconds.

How to achieve this. Any suggestions are highly appreciated. Thanks.

UIWebView first request too slow

I am using UIWebView to render web content in my application. I observed that the initial request when the app launches i.e. loadRequest, takes a long time to render the contents. However the subsequent requests which I don't track of, are much faster.
To confirm this, I created a standalone application which just has a UIWebView. This is the single line of code which I have added :

[wkBrowser loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"https://www.yahoo.com"]]];

The result is same. It takes around 15-20 seconds to load the page. However on tapping any link on web page, it takes 3-5 seconds to load the next page. I did put the UIWebView delegate function didFailLoadWithError, but there is never an error.
Question:

  1. Why is the first web request so slow ?
  2. How may I make it faster other than caching ?

how to create invoice using ApI in ios

I tried to create invoice of paypal using the follwing url invoiceurl

I wrote the following code

 NSURL *url = [NSURL  URLWithString:@"http://ift.tt/1rqEcHT"];

NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
NSData *requestData = [NSData dataWithBytes:[jsonString UTF8String] length:[jsonString length]];

[request setHTTPMethod:@"POST"];
[request setValue:@"sender_ssa_api1.gmail.com" forHTTPHeaderField:@"X-PAYPAL-SECURITY-USERID"];
[request setValue:@"AYL24E5YABQJ7S3Q" forHTTPHeaderField:@"PAYPAL-SECURITY-PASSWORD"];
[request setValue:@"A9kCtldabx3cNH-JvrasyD5dOesXAF61m6tDSZ.A7OCniSLwPFV0-A5e" forHTTPHeaderField:@"X-PAYPAL-SECURITY-USERID"];
[request setValue:@"APP-80W284485P519543T" forHTTPHeaderField:@"X-PAYPAL-APPLICATION-ID"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[request setValue:[NSString stringWithFormat:@"%lu", (unsigned long)[requestData length]] forHTTPHeaderField:@"Content-Length"];
[request setHTTPBody: requestData];

[NSURLConnection connectionWithRequest:request delegate:self];
}

- (void) connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
 NSMutableData *d = [NSMutableData data];
 [d appendData:data];

NSString *a = [[NSString alloc] initWithData:d encoding:NSASCIIStringEncoding];

NSLog(@"Data: %@", a);
}

I got authentication error. Please help me how to do it in ios.

thanks inadvance

dealing with different screen sizes in xcode

I have an iPhone game that was first developed for iPhone 6 and when played on the iPhone 5 sim it works fine but when played on the iPhone 4 sim the sides are stretched out?!? and the nodes that I spawn in from the left and the right side spawn on the screen instead of off the screen like on the iPhone 6 and 5. (please don't say this is a duplicate as I have been looking for weeks of how to deal with different iPhones)

I have arrows coming in the from the left and the right that spawn randomly on the y axis. They spawn off screen then slowly move on screen than move quickly across the screen but on the iPhone 4 the arrows spawn on the screen. this is the code for one of the arrows

-(void) leftArrow
{
    int randomY = arc4random() % (675 - 175);
    int yPoint = randomY + 175;
    leftArrow = [SKSpriteNode spriteNodeWithImageNamed:@"arrow"];

    leftArrow.size = CGSizeMake(leftArrow.size.width/1.2, self.frame.size.height/22);
    leftArrow.position = CGPointMake(CGRectGetMidX(self.frame) - 230, yPoint);
    leftArrow.zPosition = 50;
    leftArrow.alpha = 1;

    SKAction* action1 = [SKAction moveToX:leftArrow.position.x + 30 duration:0.5];
    SKAction* wait = [SKAction waitForDuration:0.75];
    SKAction* action2 = [SKAction moveToX:leftArrow.position.x + 470 duration:1.5];
    SKAction* sequence = [SKAction sequence:@[action1,wait,action2,destroy]];

    [self addChild:leftArrow];
    if (deadDown == 1 || deadUp == 1 || didIntersect == true)
    {
        [leftArrow runAction:destroy];
    }
    else
    {
        [leftArrow runAction:sequence completion:^{
            if (ii != 1)
            {
                if (didIntersect != true)
                {
                    score++;
                    if (score == 100)
                    {
                        backgroundScore.fontSize = 300;
                        backgroundScore.position = CGPointMake(backgroundScore.position.x, backgroundScore.position.y + 30);
                }
                strFromInt = [NSString stringWithFormat:@"%d",score];
                backgroundScore.text = strFromInt;
                }
            }
        }];
    }
}

I am also using this in my didmovetoview function

self.scaleMode = SKSceneScaleModeAspectFill;

How to form ticket fare ascending and descending order form array in objective c

My Array Values are

20, 30, 25, 50, "600/500", "410/360"

Thanks in advance

Get Favourite Marked Tweets Updated Date

I am integrating Twitter in an iOS app. The functionality is that i have to get all tweets that are marked favorite within last 24 hours.

I am using "STTwitterAPI" library for getting tweets.

Here is my request:-  
 `STTwitterAPI *twitter = [STTwitterAPI twitterAPIWithOAuthConsumerKey:@"ConsumerKey" consumerSecret:@"consumerSecret" oauthToken:@"oauthToken" oauthTokenSecret:@"oauthTokenSecret"];
`

`[twitter getFavoritesListWithUserID:nil screenName:nil count:nil sinceID:nil maxID:nil includeEntities:nil successBlock:^(NSArray *statuses){
  NSLog(@"%@",statuses);
}
`

So thats how i am requesting for favourites tweets.
The response coming is that:-

`
contributors = "<null>";
    coordinates = "<null>";
    "created_at" = "Mon May 11 06:20:03 +0000 2015";
    entities =     {
        hashtags =         (
        );
        symbols =         (
        );
        urls =         (
        );
        "user_mentions" =         (
        );
    };
    "favorite_count" = 1;
    favorited = 1;
    geo = "<null>";
    id = xxxxxxxxxxxxxxxxxxxxx;
    "id_str" = xxxxxxxxxxxxxxxxxxxxx;
    "in_reply_to_screen_name" = "<null>";
    "in_reply_to_status_id" = "<null>";
    "in_reply_to_status_id_str" = "<null>";
    "in_reply_to_user_id" = "<null>";
    "in_reply_to_user_id_str" = "<null>";
    lang = en;
    place = "<null>";
    "retweet_count" = 0;
    retweeted = 0;
    source = "<a href=\"http://twitter.com\" rel=\"nofollow\">Twitter Web Client</a>";
    text = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
    truncated = 0;
    user =     {
        "contributors_enabled" = 0;
        "created_at" = "Mon Apr 13 12:15:45 +0000 2015";
        "default_profile" = 1;
        "default_profile_image" = 1;
        description = "";
        entities =         {
            description =             {
                urls =                 (
                );
            };
        };
        "favourites_count" = 56;
        "follow_request_sent" = 0;
        "followers_count" = 0;
        following = 0;
        "friends_count" = 2;
        "geo_enabled" = 0;
        id = xxxxxxxxxxxxxxxxxxxxx;
        "id_str" = xxxxxxxxxxxxxxxxxxxxx;
        "is_translation_enabled" = 0;
        "is_translator" = 0;
        lang = en;
        "listed_count" = 0;
        location = "";
        name = "xxxxxxxxxxxxxxxxxxxxx";
        notifications = 0;
        "profile_background_color" = C0DEED;
        "profile_background_image_url" = "http://ift.tt/1eDsrLj";
        "profile_background_image_url_https" = "http://ift.tt/1dEhDZS";
        "profile_background_tile" = 0;
        "profile_image_url" = "http://ift.tt/1hc50JK";
        "profile_image_url_https" = "http://ift.tt/18sbEJA";
        "profile_link_color" = 0084B4;
        "profile_sidebar_border_color" = C0DEED;
        "profile_sidebar_fill_color" = DDEEF6;
        "profile_text_color" = 333333;
        "profile_use_background_image" = 1;
        protected = 0;
        "screen_name" = "xxxxxxxxxxxxxxxxxxxxx";
        "statuses_count" = 11;
        "time_zone" = "<null>";
        url = "<null>";
        "utc_offset" = "<null>";
        verified = 0;
    };
`



I am getting all the favorite marked tweets but i am getting their created date only. Is there ant way so that i can also find their favorite marked time and date too????

Suppose i ahev a tweet that i have created 3 months ago. Now i marked him favourite 30 mins ago. So the time that i require is 30 mins previous to current time not the time 3 months ago. Is there any Suggestions???

Please Reply Soon....

Thanks...

how to update UILabel using sockets

I am trying to update a UILabel using swift and sockets. I have a Mean stack app working with sockets now. It updates a simple counter when a user presses a button. How could I use sockets and update a UILabel when a user presses a button on the client side of my Mean stack app? Below is the swift code I'm using to update the counter. Any help or suggestions would be greatly appreciated.

import Foundation
import UIKit

class SocketsController: UIViewController, UIAlertViewDelegate {

@IBOutlet weak var socketLabel: UILabel!

@IBAction func buttonOnePressed(sender: UIButton) {
    socket.emit("javascript")
}

@IBAction func buttonTwoPressed(sender: UIButton) {
    socket.emit("swift")

}


let socket = SocketIOClient(socketURL: "192.168.15.92:8000")

override func viewDidLoad() {
    super.viewDidLoad()
    socket.connect()

    socket.on("connect") { data, ack in
        println("iOS::WE ARE USING SOCKETS!")

    }
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}

}

IOS Cross Promotion?

I am a new and ambitious IOS App Developer. I am looking for other ambitious IOS app developers to cross promote with. I have a utilities app coming out soon and would like to cross promote with other IOS developers with utility apps.

I have been searching for quite sometime for people to cross promote with. I would really like to give and receive traffic so we can both benefit.

Thank you!

Quickblox: Messages not saved on quickblox Admin panel

I am using quickBlox in my Application, We have to give sync feature in our application. so we have created a API which will call quickBlox API to get message's of that user, now my problem is that when ever I start new chat (chat with new user) at that time 2-3 messages are stored on Admin Panel, but rest of the message are not getting stored.

I have added save flag to in my code. can you please suggest me what can I do?

QBChatMessage *message = [[QBChatMessage alloc] init];

NSMutableDictionary *paramaterDict = [self prepareDictionaryForMessage:strURL strAttachType:strAttachType];

message.text = [paramaterDict JSONRepresentation];
NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
params[@"save_to_history"] = @YES;

long timeStamp = [[NSDate date] timeIntervalSince1970];
params[@"date_sent"] = [NSString stringWithFormat:@"%ld",timeStamp];

[message setCustomParameters:params];

IOS & objective C development - how to make the login page appear to the user?

I am in my first days of IOS app development, I am trying to build an authentication system for an already existent iOS App using Objective C.

The app's rootviewcontroller is a tabsview followed by navigationControllers.

What i've done so far:

1- creating the loginviewController class & designing it's UI in the storyboard

2- the same thing for the "registration" & "recover my password" classes

3- linking the root viewcontroller with the login page with a segue of type modal.

4- linking the login page with the registration & recover my password pages with segues of type push.

Now i don't know the steps that i should follow to make the login page appear to the user when he first enters the app & eventually store his state so he can access the app later without having to enter his credentials every time (unless he logs out).

Any help is greatly appreciated, thank you

I am available for any clarifications or eventually some screenshots/source code if needed.

Edit 1 : this is the content of my didFinishLaunchingWithOptions method in my appdelegate.m :

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    TabsViewController *controller = (TabsViewController *)self.window.rootViewController;


    controller.managedObjectContext = self.managedObjectContext;
    _observer = [[MyStoreObserver alloc] init];
    [[SKPaymentQueue defaultQueue] addTransactionObserver:_observer];

    //Create sub directories in doesn'n exist
    NSString *documentsDirectory =[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
    NSString *pathToFile = [documentsDirectory stringByAppendingString:@"export"];
    BOOL isDir = YES;
    BOOL isFile = [[NSFileManager defaultManager] fileExistsAtPath:pathToFile isDirectory:&isDir];

    if(isFile)
    {
        //it is a file, process it here how ever you like, check isDir to see if its a directory
    }
    else
    {
        [self createSubDirectories];
        //not a file, this is an error, handle it!
    }


    return YES;
}

What should I add/change ??

How to create Date and slot picker in iOS like attached image?

I want to create a date and slot picker in iOS like Meru cab mobile application.

Please check the attached the screenshot for your reference.

Can we create a control like that?

Any help would be appreciated.

http://ift.tt/1EUbQ2E

dimanche 10 mai 2015

Changing array in another class programmatically

I am programmatically presenting a view controller (SavedGames.swift -> OnePlayer.swift), and I cannot figure out how to change the array in the view controller I am presenting (OnePlayer.swift) in the original controller (SavedGames.swift). I want to change tableData in OnePlayer in the block of code in SavedGames.swift.. Hope that makes sense

SavedGames.swift:

        if let resultController = storyboard!.instantiateViewControllerWithIdentifier("OnePlayer") as? OnePlayer {
            presentViewController(resultController, animated: true, completion: nil)

            //in OnePlayer, set tableData to this tableData: [String] = ["one", "two", "three"]
        }

OnePlayer.swift:

var tableData: [String] = ["zero", "zero", "zero"]

ios not get other finger (multitouch) event in UILongPressGestureRecognizer

How can I get multitouch and single touch event?

I try to touch moving (not touch up) left finger, now I click right finger on the screen, But I try to get right finger touch event or touch point.

I set the log [gesture numberOfTouches] or [gesture numberOfTouchesRequired]. I still get 1, not get 2.

In my ViewDidLoad method I set below code:

 - (void)viewDidLoad {
     [super viewDidLoad];
 self.view.multipleTouchEnabled =  YES;
 self.view.exclusiveTouch = NO;

 UILongPressGestureRecognizer *panelLongPressGestureRecognizer =
 [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(panelLongPressRecgonizerAction:)];
 panelLongPressGestureRecognizer.delegate = self;

//panelLongPressGestureRecognizer.numberOfTapsRequired = 1;
//panelLongPressGestureRecognizer.numberOfTouchesRequired = 1;
panelLongPressGestureRecognizer.minimumPressDuration = 0.001;
 [self.view addGestureRecognizer:panelLongPressGestureRecognizer];


 UILongPressGestureRecognizer *panelLongDoublePressGestureRecognizer =
 [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(panelLongPressRecgonizerAction:)];
 panelLongDoublePressGestureRecognizer.delegate = self;
 panelLongDoublePressGestureRecognizer.numberOfTapsRequired = 2;
 panelLongDoublePressGestureRecognizer.numberOfTouchesRequired = 2;
 panelLongDoublePressGestureRecognizer.minimumPressDuration = 0.001;
 [self.view addGestureRecognizer:panelLongDoublePressGestureRecognizer];
 }

 - (void)panelLongPressRecgonizerAction:(UILongPressGestureRecognizer *) gestureRecognizer
 {
 switch (gestureRecognizer.state) {
    case UIGestureRecognizerStateBegan:
        NSLog(@" === long press began ===");
        break;
    case UIGestureRecognizerStatePossible:
        break;
    case UIGestureRecognizerStateChanged:
        NSLog(@" === long press changed ===");
        [self pressChanged:gestureRecognizer];
        break;
    case UIGestureRecognizerStateEnded:
        NSLog(@" === long press end ===");
        break;
    case UIGestureRecognizerStateCancelled:
        NSLog(@" === long press cancell ===");
        break;
    case UIGestureRecognizerStateFailed:
        NSLog(@" === long press failed ===");
        break;


}
NSLog(@" ");

}

- (void) pressChanged:(UILongPressGestureRecognizer *) gesture
{
    NSLog(@"moved guesture.number of touches:%ld", [gesture numberOfTouches]);
    NSLog(@"moved numberOfTouchesRequired of touches:%ld", [gesture numberOfTouchesRequired]);

}

I still get log:

 2015-05-11 14:25:46.117 DroneG2[7521:1149008]  === long press changed ===
 2015-05-11 14:25:46.118 DroneG2[7521:1149008] moved guesture.number of touches:1
 2015-05-11 14:25:46.118 DroneG2[7521:1149008] moved numberOfTouchesRequired of touches:1

Have anyone know where is my question in my code?

I want to get other finger touch point or event when I moving?

thank you very much.

Multiline NSString with a character limit per line

I want to construct a multi line NSString (for printing purpose) with a character limit per line. Each line should have maximum of 25 characters. Number of lines can be anything based on the length of the string. This is my approach which is not the best I guess. Whats is the best way to do this without manually checking the length of the string?

NSMutableString* strCustomerComments = [NSMutableString string];

if([[[arrItems objectAtIndex:0]objectForKey:@"CustomerComment"] length]<=25){
            [strCustomerComments appendString:[NSString stringWithFormat:@"%@",[[arrItems objectAtIndex:0]objectForKey:@"CustomerComment"]]];
}
else{

     [strCustomerComments appendString:[NSString stringWithFormat:@"%@\n%@",[[[arrItems objectAtIndex:0]objectForKey:@"CustomerComment"] substringToIndex:25],[[[arrItems objectAtIndex:0]objectForKey:@"CustomerComment"] substringFromIndex:25]]];
   }