Is there away to measure latency for one specific page?
Can I do some requests and calculate the average to know the latency?
Is there away to measure latency for one specific page?
Can I do some requests and calculate the average to know the latency?
I need to convert
3/27/2015 5:45:00 AM
string into an NSDate object.
I tried this;
[dateFormatter setDateFormat:@"MM/dd/yyyy hh:mm:ss a"];
but it does not work.
What might be wrong that i could not figure out?
Thanks
I'm working on a cordova app
on which I have to locate the user
latitude and longitude. Using the geolocation plugin, it works fine on android devices but it display an alert asking for permission from user in iOS
. When I used the simulator I get this alert message:
Users/user/Library/Developer/CoreSimulator/Devices/783A2EFD-2976-448C-8E4E-841C985D337D/data/Containers/Bundle/Application/EFC846BB-4BA3-465C-BD44-575582E649FC/app_name.app/www/index.html would like to use your current location.
I have seen topic talking about this problem like: this but none of the provided solutions works for me.
this is my geolocation function:
function loadMyCoordonnee() {
if (navigator.geolocation) {
navigator.geolocation
.getCurrentPosition(
function(position) {
var myLatlng = new google.maps.LatLng(
position.coords.latitude,
position.coords.longitude);
window.localStorage.setItem("lattitude",
position.coords.latitude);
window.localStorage.setItem("longitude",
position.coords.longitude);
console.log('lattitude : '
+ window.localStorage.getItem("lattitude"));
console.log('longitude : '
+ window.localStorage.getItem("longitude"));
}, function(error) {
var myLatlng = new google.maps.LatLng(
47.120547402337465, 2.651801171874922);
window.localStorage.setItem("lattitude",
47.1205474023374655);
window.localStorage.setItem("longitude",
2.651801171874922);
});
} else {
window.location = "index.html";
}
}
and here where I called this function:
var app = {
initialize: function() {
this.bindEvents();
},
bindEvents: function() {
document.addEventListener('deviceready', this.onDeviceReady, false);
},
onDeviceReady: function() {
loadMyCoordonnee();
//app.receivedEvent('deviceready');
},
receivedEvent: function(id) {
var parentElement = document.getElementById(id);
var listeningElement = parentElement.querySelector('.listening');
var receivedElement = parentElement.querySelector('.received');
listeningElement.setAttribute('style', 'display:none;');
receivedElement.setAttribute('style', 'display:block;');
console.log('Received Event: ' + id);
}
};
app.initialize();
Is there any way to change the text of the alert or to disable this alert?
I'm currently working on implementing a horizontally scrollable photo gallery feature. For this, I'm using UICollectionView with the flow layout set to horizontal. The problem that I'm currently facing is with the orientation. Lets say, I launched this view in landscape and i scrolled across couple of photos and now if change orientation to portrait, i'm loosing the position where i was before in the landscape mode. i want to make sure i show the same photo centered vertically that i have before changing the orientation. please find the included source code below.
class ViewController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout {
var collectionView: UICollectionView!
private var samplePictures:[UIImage] = []
let CELL_IDENTIFIER = "photo_cell"
var currentIndex = 0
var flowLayout: UICollectionViewFlowLayout!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
samplePictures = [UIImage(named: "Photo-1.png")!, UIImage(named: "Photo-2.png")!, UIImage(named: "Photo-3.png")!, UIImage(named: "Photo-4.png")!, UIImage(named: "Photo-5.png")!, UIImage(named: "Photo-6.png")!]
flowLayout = UICollectionViewFlowLayout()
flowLayout.scrollDirection = UICollectionViewScrollDirection.Horizontal
flowLayout.minimumInteritemSpacing = 0.0
flowLayout.minimumLineSpacing = 0.0
flowLayout.sectionInset = UIEdgeInsetsMake(0.0, 0.0, 0.0, 0.0)
collectionView = UICollectionView(frame: self.view.bounds, collectionViewLayout: flowLayout)
collectionView.delegate = self
collectionView.dataSource = self
collectionView.showsHorizontalScrollIndicator = false
collectionView.showsVerticalScrollIndicator = false
collectionView.autoresizingMask = UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleWidth
collectionView.pagingEnabled = true
collectionView.registerClass(SampleCollectionCell.self, forCellWithReuseIdentifier: CELL_IDENTIFIER)
self.view.addSubview(collectionView)
}
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
collectionView.reloadData()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int {
return 1
}
func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return samplePictures.count
}
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
var cell = collectionView.dequeueReusableCellWithReuseIdentifier(
CELL_IDENTIFIER, forIndexPath: indexPath) as SampleCollectionCell
cell.backgroundColor = UIColor.brownColor()
cell.imageView_sample.image = samplePictures[indexPath.item]
return cell
}
func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize {
return self.view.bounds.size
}
override func viewWillTransitionToSize(size: CGSize, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator) {
super.viewWillTransitionToSize(size, withTransitionCoordinator: coordinator)
collectionView.collectionViewLayout.invalidateLayout()
}
//supports all orientations
override func supportedInterfaceOrientations() -> Int {
return Int(UIInterfaceOrientationMask.All.rawValue)
}
//view will rotate when the interface orientation happens
override func shouldAutorotate() -> Bool {
return true
}
}
This is the source code for the CustomCollectionCell that I'm using
class SampleCollectionCell: UICollectionViewCell {
var imageView_sample: UIImageView!
override init(frame: CGRect) {
super.init(frame: frame)
imageView_sample = UIImageView(frame: self.bounds)
imageView_sample.contentMode = UIViewContentMode.ScaleAspectFit
self.contentView.addSubview(imageView_sample)
}
required init(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func layoutSubviews() {
super.layoutSubviews()
self.imageView_surveillance.frame = self.bounds
}
}
Any help is truly appreciated. The core idea behind using this is to mimic the Photo app and also update view components when i scroll a picture. Please suggest if you think this can be done in a better way.
Regards.
I am trying to show a tableview just below the text field. I am having 5 text field in this page. I want to show the same table on all the 5 text fields (created the table programatically) please can any one help me
[!] Unable to add a source with url git@github.com:CocoaPods/Specs.git
named master-1
. You can try adding it manually in ~/.cocoapods/repos
or via pod repo add
. please any help
In my project,i have a 1.MovieplayerView,2.a label with dynamic content,3.a tableView with variable number of rows.
I was doing this with all these views in scrollView.But i always have the issue with dynamic height of the label.it sometime overlaps the tableView.
I came to know that we can use customView as the tableView header.How this can be done with variable content Height and autolayout?I am new to iOS.Any suggestion ??
I know how to add a view as the header to a table.But when the contents in the view changes,it overlaps the contents of the tableView.
I went through How to resize superview to fit all subviews with autolayout?,How do I set the height of tableHeaderView (UITableView) with autolayout?
Can some one give a simple example on how to do this?Or tell me if it is better to use a scrollview and add all these views as its subviews? any suggestion would be realy helpful.Thanks.
I have a simple application and I am now implementing In App Purchases. The layout of the problem at hand is simple:
IAPViewController
which contains the elements like a UIButton and UILabele100EntriesPurchase
which is what is doing the actual IAPs.When the user clicks on an element like a UIButton
in the IAPViewController
, it invokes a method in the e100EntriesPurchase
class which shows a UIAlertView
to the user. The otherButtonTitle
has a formatted text to show the price in your local country.
- (void)displayStoreUI
{
// Obtain formatted price
[self obtainPurchasePricing];
NSLog(@"HERE THE PRICE IS %@", self.productPrice);
NSString *obtainedProductPrice = self.productPrice;
NSLog(@"THE OBTAINED PRODUCT PRICE IS %@", obtainedProductPrice);
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:self.productBeingPurchased.localizedTitle message:self.productBeingPurchased.localizedDescription delegate:self.delegate cancelButtonTitle:obtainedProductPrice otherButtonTitles:@"Maybe later", nil];
alertView.tag = 999;
[alertView show];
}
- (NSString *)obtainPurchasePricing
{
// Displays Local Currency
NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
formatter.formatterBehavior = NSNumberFormatterBehavior10_4;
formatter.numberStyle = NSNumberFormatterCurrencyStyle;
formatter.locale = self.productBeingPurchased.priceLocale;
self.productPrice = [NSString stringWithFormat:@"Buy this for %@", [formatter stringFromNumber:self.productBeingPurchased.price]];
NSLog(@"The price is %@", self.productPrice);
return self.productPrice;
}
All of the NSLogs
are showing the price appropriately.
Now from my IAPViewController
, I want the title of the UIButton
to be the same as what it is set in the obtainPurchasePricing
method, so:
NSString *obtainedPrice = [self.e100EntriesPurchase obtainPurchasePricing];
[self.iap100Button setTitle:obtainedPrice forState:UIControlStateNormal];
NSLog(@"The price is %@", obtainedPrice);
The problem I am facing is that the title of the UIButton
is "Buy Now for (null)". The NSLog
also doesn't show the actual price. This code above is in the viewDidLoad
of the IAPViewController
.
The properties in the e100EntriesPurchase
class are:
@property (nonatomic, strong) SKProduct *productBeingPurchased;
@property (nonatomic, strong) NSString *productPrice;
What am I missing to obtain the actual price?
Any thoughts on this would really be appreciated!
Update
Through some extensive debugging, I have seen the pattern for what goes on when the UIButton
is pressed (because at that point, the price is displayed correctly and therefore self.productsBeingPurchased
is not nil).
- (void)validateProductIdentifiers
{
// Asking the App Store - I'm supposed to buy this product, does it exist? If it does, we'll get back a product.
NSLog(@"validateProductIdentifiers");
SKProductsRequest *request = [[SKProductsRequest alloc] initWithProductIdentifiers:[NSSet setWithArray:self.iap100EntriesPurchase]];
// Set the delegate
request.delegate = self;
// Call the start method on that request
[request start];
}
- (void)makeThePurchase
{
NSLog(@"makeThePurchase");
SKPayment *payment = [SKPayment paymentWithProduct:self.productBeingPurchased];
[[SKPaymentQueue defaultQueue]addPayment:payment];
}
- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
{
NSLog(@"productsRequest");
// This method is saying there is a product request and is there a response reeived.
// We'll grab a reference to that product.
// There is only one product on iTunes Connect, so we can just grab that product. With more than one, we'd have to loop through all of the available products.
// grab a reference to our product.
self.productBeingPurchased = response.products.firstObject;
// Now that we have a product, let's display a store UI.
if ([SKPaymentQueue canMakePayments])
{
// Can we actually buy thigns? Yes we can buy stuff. It's a good idea to check this. We'll create a method to display the store UI.
[self displayStoreUI];
}
else
{
// in app purchaes are disabled in the settings
[self cantBuyAnything];
}
}
From the IAP
, if I run [self.e100EntriesPurchase validateProductIdentifiers]
before calling the obtainPurchasePricing
, it still shows NULL
as the button title (Buy Now for NULL), but it then invokes the displayStoreUI
method after a few seconds, so that's clearly not right.
Possible Duplicate
The question has been marked as a possible duplicate, but none of the answers in the proposed question work for me; the issue is still the same even after I've set up the delegate mechanism.
I am trying to create a screen where scrolling is required in iphone 3.5 inch screen . I have attached images which contain the configuration of uiviewcontroller , uiscrollview , uiview . The problem is eventhough the height seems to increase , when i run iPhone 4s , some part of scroll is hidden beyond the UIView (Although uiview height shows 700 when i print the height in console) . What might be the problem ? Please help me ?
I implemented new pushkit voip push notifications and until now it has been working properly in all iOS8 devices I tested except one. I ve got an iPhone iOS 8.0.2 which is not receiving any voip push. It registers correctly as I get the pushRegistry:didUpdatePushCredentials: forType: delegate called I tested previous remote pushes (registerForRemoteNotifications) with success but none of sent voip push are received.
So my questions are:
*Anyone has experienced same behavior for pushkit voip push notifications?
*Could it be something related with iOS version (iOS 8.0.2)?
*Could anyone having this version (iOS 8.0.2), implementpushkit voip push and try to receive a voip push notification in order to discard version problem?
If you need to implement pushkit voip push notifications you can check my answer on stackoverflow question
I tried to rename my project in xcode, but when I tried to go to a second view controller, everything crashed. So, I tried to rename it one more time. But now I am really stuck...
It is now saying that it is running 'myNewName.temp_caseinsensitive_rename' on iPhone and still everything crashes when I go to the second view controller. But now, I cannot change it. Everytime I change it, the '.temp_caseinsensitive_rename' is still there... Crap, What should I do! I am really lost now...
I am using xcode 6.2 on Mavericks.
I would like to know if is possible use WKWebView with cordova. And if this is possible, how I can use.
I read that cordova 4.0 maybe will use WKWebView, but I can't find if this is in production.
I'm writing my first swift universal app. I have used Sqlite3 in objective-c apps before so I would like to think i have a fairly decent knowledge of it. I'm using Sqlite3 to store data that is downloaded from a server when the app first loads. The problem i'm having is that when I run the app on the IOS simulator it works just fine, however when I run it on an actual device it doesn't seem to be creating the database file.
I have the following code
func dataFilePath() -> String
{
let documentDirectory = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0] as String
return documentDirectory
}
func dataFile() -> String
{
return "App.sqlite3"
}
func InitialiseDatabase()
{
var databaseName = dataFilePath()
databaseName += dataFile()
var database:COpaquePointer = nil
var result = sqlite3_open(databaseName, &database)
if result != SQLITE_OK {
println(sqlite3_errmsg(database));
sqlite3_close(database)
return
}
.......... more code here
When this runs it is not returning SQLITE_OK on the actual device. I'm wondering if it's some sort of permissions issue? sqlite_3_errmsg just returns some code which doesn't bring up any results on google so that hasn't helped.
Any ideas?
I have a very simple app with two viewControllers at the moment. I have a transition between them (with a segue of course) and both screens have a lot of images and buttons with images.
What I discovered was that there is a memory leak when you alternate between the screens. I am guessing, that somehow the images are loaded again each time you open the viewController again. Around 6MB is added each time and I am pretty sure that the images are less than 1MB in total. So maybe there is something else craving all the memory?
I have 6 image Views and I use the cross dissolve transition in the default modus. I wish I could copy some code here, but it is a big project and I would not know what code would be helpful.
So my question would be: what is causing this problem (and preferable how can I fix this)? Is it the images, or maybe the segues with the transition.
Any help would be really appreciated! Thanks!
Does anyone know if you can keep your app in TestFlight during the approval process?
A common way to dismiss a modal is to swipe down - How do we allows the user to drag the modal down, if it's far enough, the modal's dismissed, otherwise it animates back to the original position?
For example, we can find this used on the Twitter app's photo views, or Snapchat's "discover" mode.
Similar threads point out that we can use a UISwipeGestureRecognizer and [self dismissViewControllerAnimated...] to dismiss a modal VC when a user swipes down. But this only handles a single swipe, not letting the user drag the modal around.
My app is live on the app store. I made an update with changes to the core data model. I followed the core data light migration on Apple dev website.
Here is the code:
NSString *momdPath = [[NSBundle mainBundle] pathForResource:@"PropertiesModel" ofType:@"momd"];
model = [[NSManagedObjectModel alloc] initWithContentsOfURL:[NSURL fileURLWithPath:momdPath]];
// model = [NSManagedObjectModel mergedModelFromBundles:nil];
psc = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:model];
NSString *path = [self itemArchivePath];
NSURL *storeURL = [NSURL fileURLWithPath:path];
NSError *error = nil;
NSDictionary *options = @{ NSMigratePersistentStoresAutomaticallyOption : @(YES),
NSInferMappingModelAutomaticallyOption : @(YES),
NSSQLitePragmasOption : @{@"journal_mode" : @"DELETE"}};
if (![psc addPersistentStoreWithType:NSSQLiteStoreType
configuration:nil
URL:storeURL
options:options
error:&error]) {
CLS_LOG(@"store URL: %@ \n options: %@ \n error: %@",storeURL,options,error);
[NSException raise:@"Open failed" format:@"Reason: %@, Full Error: %@", [error localizedDescription],error];
}
// Create the managed object context
context = [[NSManagedObjectContext alloc] init];
[context setPersistentStoreCoordinator:psc];
I keep running into this error that it cannot find my original (old version) model. The weird thing is when I tested it during development, it worked. I released to the app store and now it is crashing on all my user's device.
Error Domain=NSCocoaErrorDomain Code=134130 "The operation couldn’t be completed. (Cocoa error 134130.)" UserInfo=0x170671dc0 {URL=file:///var/mobile/Containers/Data/Application/68165624-8866-4722-8472-F371A1202A83/Documents/DIYLandLord.data, metadata={
NSPersistenceFrameworkVersion = 519;
NSStoreModelVersionHashes = {
Contractor = <6e29455a 13768a19 a9a4a2da 1d8d492e b3cc023d bc06cb0d 298b56e1 b44fba9f>;
Expense = <847aa2e8 da0a2730 4b0a70a2 2051ed2c 09ece5c4 e1a39c10 a42f0aa2 d5b79ad4>;
InAppPurchase = <51dc7a31 415ba244 9c175d8f e14f6948 7ebec6a3 463d2995 3ad0b60b 8bd06f7d>;
Owner = <2eaaaa38 ff6c4d19 6bb2621b 91a2c61a 9f5e564e 4703c68c 880f8ab4 4e1d2408>;
Payment = <e92d19bd 82637935 88cf8493 e0c73ddc d1ba245e 0d1e49e4 8c6bc876 e9a97372>;
Property = <456365b5 9f1b3cda 92f663ef 5f8b90a1 4dc5842b 20f58a7c 4521f182 f733e99f>;
Tenant = <f3a92b85 dace78cb ae9cba8f 73419929 6932ca12 4ff97ebf 8e2d7689 da9c242b>;
Unit = <922b8c16 930cd7b7 05259da0 79ace226 bd379991 955bfc4a 755a72ef 1e5dac4c>;
};
NSStoreModelVersionHashesVersion = 3;
NSStoreModelVersionIdentifiers = (
""
);
NSStoreType = SQLite;
NSStoreUUID = "27CE8843-4E80-4F4A-A728-559465D687F8";
"_NSAutoVacuumLevel" = 2;
}, reason=Can't find model for source store}
I tried to revert back to the code base of the last stable release version in the app store but I also runs into a core data error "the model is not compatible with the store" or something like that.
This is driving me nut. Could someone shed some light on this issue please?
When I run a single XCTest class, all tests within succeed.
However when I run it together with other XCTest, some tests in the class fail.
setUp and tearDown method are implemented correctly as following:
- (void)setUp {
[super setUp];
...
}
- (void)tearDown {
...
[super tearDown];
}
Does anyone know why this might happen?
Thanks a bunch!
I have a CoreDataManager.Swift where I delegated the creation of PersistentStore Coordinator, ManagedObjectContext and NSManagedObjectModel
I have the following function where Entity is a NSManagedObject and timeStamps is NSOrderedSet. In data model timeStamps is one to many relationship to another NSManagedObject TimeStamp
func fetchData(){
let fetchRequest = NSFetchRequest(entityName:"Entity")
var error: NSError?
let fetchedResults =
CoreDataManager.sharedInstance.managedObjectContext!.executeFetchRequest(fetchRequest,
error: &error) as! [NSManagedObject]?
//If error then return...
for entity in fetchedResults as! [Entity]
{
println(entity.name)
println(entity.timeStamps)
for eS in entity.timeStamps
{
println(eS.time) //OK in AppDelegate but throw compilation error in CoreDataManager.swift
// Error thrown is AnyObject does not have a member name time
//If I force to TimeStamp then the fault on timeStamps is not fired.
}
}
}
The issues is, it works fine if I have that function in AppDelegate but throws compilation errors in CoreDataManager. If I try to force it as TimeStamp then the fault on timeStamps is not fired.
Thanks for any help
Hi I have a spriteKit game set up where everytime the user dies Ill get a pop up ViewController with Try again button and some iAds set up.
I have a segue to the viewController and an unwind segue from the VC to the gameViewController.
When I call the unwind func I reinitialize the scene for different reasons. My question is, am I creating view over view which will eventually lead to a crash or am I correctly reinitializing the scene. I took the code from viewDidLoad and put it into a function called "setUp()" and I call that function from the unwindSegue.
check it out: (all in GameViewController)
var currentLevel: Int!
var gameScene = GameScene()
override func viewDidLoad() {
super.viewDidLoad()
currentLevel = gameScene.currentLevel
setUp()
}
@IBAction func perpareForUnwind(unwindSegue: UIStoryboardSegue) {
setUp()
}
func setUp() {
if let scene = GameScene.level(currentLevel) {
// Configure the view.
let skView = self.view as SKView
skView.showsFPS = true
skView.showsNodeCount = true
/* Sprite Kit applies additional optimizations to improve rendering performance */
skView.ignoresSiblingOrder = true
/* Set the scale mode to scale to fit the window */
scene.scaleMode = .AspectFill
skView.presentScene(scene)
scene.viewController = self
}
}