mardi 4 août 2015

AFNetworking caching using ETag

I have problem implementing caching using AFNetworking and ETag values. My server returns Cache-Control and ETag headers values for every request. But if I make a second request for the same resource AFNetworking won't add ETag. Should I manually save etag for each response I got and append it to next requests?

In app delegate I have set cache object:

 NSURLCache *URLCache = [[NSURLCache alloc] initWithMemoryCapacity:20 * 1024 * 1024 diskCapacity:20 * 1024 * 1024 diskPath:nil];
 [NSURLCache setSharedURLCache:URLCache];

Also, I'm using default cache policy of AFHTTPRequestSerializer.

Any ideas what is the problem? Maybe I don't understand the idea of http caching. As far as I know it should be transparent, and all I have to do is to attach ETag and Cache-Control headers for every response.

Annotation pins and detail view from sqlite in Xcode

I've been looking around the internet to find a tutorial or something to explain this:
I need to show some pins on a map. I need to get them from a sqlite database (table with POI's name, lat, lon, and some text). They have to show annotations callouts with title and subtitle and open their detail views. All that with Xcode and Objective-C. How can I do that? Can anybody help and write the code?

How to map my Objective-C errors like Swift 2 does for NSURLError, NSCocoaError, AVError, etc. as described in WWDC 2015 video 401?

@13:20 into the WWDC video "Swift handling of Cocoa errors" (http://ift.tt/1cQOUHP) Apple shows how they have exposed their errors from Cocoa (at least some classes) as something like NSURLError.someError. These errors can then be used nicely with Swift 2 catch syntax.

This part of the video shows that this (for errors from certain Cocoa classes) is now possible:

func preflight() -> Bool {
  do {
    try url.checkResourceIsReachable()
    resetState()
    return true
  } catch NSURLError.FileDoesNotExist {
    return true // still okay
  } catch {
    return false
  }
}

Note the fact that Cocoa error NSURLErrorFileDoesNotExist is somehow mapped or usable in Swift as NSURLError.FileDoesNotExist (in the catch expression)

I'd like to have my SDK errors be able to be used in the same way.

But when I try to return an NSError from my Objective-C code, and then catch that error on the Switch 2 side, the catch block for the particular error is not invoked and the only catch block that is the ending catch-all one.

Here's how my errors are defined in Objective-C TestClass.h:

typedef NS_ENUM(NSInteger, TestClassError) {
    TestClassErrorOne,
    TestClassErrorTwo,
    TestClassErrorThree,
    TestClassErrorFour,
    TestClassErrorFive,
};

Here's how I return one of these errors in my Objective-C TestClass.m:

- (BOOL)method2AndReturnError:(NSError **)err {
    // ...

    if (err) {
        *err = [NSError errorWithDomain:@"TestClassError"
                                  code:TestClassErrorTwo
                              userInfo:nil];
        NSLog(@"set error: %@", *err);
    }
    return NO;
}

The error logged here as set in the NSError is:

[...] set error: Error Domain=TestClassError Code=1 
    "The operation couldn’t be completed. (TestClassError error 1.)"

Here's how I try to catch the error in Swift 2:

    // why are the TestClassError.xxx catch blocks not catching?
    do {
        try test.method2()
    } catch TestClassError.One {
        print("error one!")
    } catch TestClassError.Two {
        print("error two!")
    } catch TestClassError.Three {
        print("error three!")
    } catch TestClassError.Four {
        print("error four!")
    } catch TestClassError.Five {
        print("error five!")
    } catch let error as NSError {
        print("error not caught!")
        print(error)
    }

And here's how the error gets logged at the end of this (from the Swift code):

Error Domain=TestClassError Code=1 "The operation couldn’t be completed. 
    (TestClassError error 1.)"

Offhandedly I think everything looks good but the catch blocks are not "catching" the errors in the form TestClassError.Two

what is typedef long dispatch_once_t in objective c

i was going through this tutorial, and i noticed they used:

typedef long dispatch_once_t

yet they did not explain what it does. Furthermore, I have no idea what does "typedef long" mean ? i tried searching through references but didnt find an answer. Can you provide an example of how typedef long works ?

How can I create a cv:Mat from UIImage/NSData?

I'm working on image recognition for our company app (iOS).

Initially what I wanted to do is: to make a photo of some digits number and try to use recognition library tesseract. The problem is: the tesseract doesn't work good enough for me. So I decided to use image recognition instead of text recognition library.

I've made pictures of numbers from 0 to 9 with the font I need with the background I need. Next I take a photo of a number (which consists of several digits). Then I wanna compare the digits to the pictures I've made. The algorithm I've found on the internet. The problem is: I have to create a cv::Mat object for the photo, which I've taken in order to make a comparison. I'm working with iOS (Objective-C), so the image object is UIImage. How can I convert the UIImage to the cv::Mat object ?

I need somehow to decode the NSData object to the cv::Mat (the NSData object I can get from the following code, where testedImage is the UIImage*)

NSData *testedImageData = UIImagePNGRepresentation(testedImage);

The only way I can do it now is to save the picture on the file system and then get it's path and create a cv::Mat object, but it's not a good idea ...

JSON parsing using [NSJSONSerialization JSONObjectWithData:dataJson options:0 error:&error] thowing nil

error = Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (Garbage at end.) UserInfo=0x7fa4e25da7c0 {NSDebugDescription=Garbage at end.}

If changing NSData to NSString , response is getting but using

id jsonData = [NSJSONSerialization JSONObjectWithData:dataJson options:0 error:&error]

showing above error, and response nil.

init instance variable multiple times

can this code cause any potential trouble?

@property (nonatomic, retain) NSDictionary *instanceDictionary;

for(int i = 0; i < 50; i++){
   self.instanceDictionary = [NSDictionary alloc] init];
}

or without self

for(int i = 0; i < 50; i++){
   instanceDictionary = [NSDictionary alloc] init];
}

I came across situations where a instance variable gets "overridden" like this and was wondering if it could cause any memory problems.

Obj-c method with nullable return value not properly converting to swift

I have a problem where the following OBJ-C method will not translate to Swift with optional return value:

- (nullable id)executeRequest:(ServerRequest *)request returningResponse:(__nullable NSURLResponse **__nullable)responseRef errorRef:(NSError **)errorRef

When trying to override that method in a swift class it translates to this:

override func executeRequest(request: ServerRequest, returningResponse responseRef: AutoreleasingUnsafeMutablePointer<NSURLResponse?>) throws -> AnyObject

Note that the return value is AnyObject instead of AnyObject?

What am I doing wrong here? I'm using X-Code 7 Beta 3

Spin Animation Resets to Original Image

For fun I have been trying to get a lottery wheel type object set up using Xcode in objective c. So far I have been able to successfully spin the object with random rotations, and stopping at 1 of 8 items on the wheel.

The problem is, I am not sure how to "save" the animation layer that is spun. Each time I spin the wheel, once the animation is completed it resets and shows the image in the original orientation. Below is the code I have setup for spinning the wheel. (NOTE: in this code I merely just have a set rotation. this is the template I am working with to try and retain the image. The other code is in a different project that stores the stopping point and corrects it to the center of on of those objects.)

ViewController.m

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

#define SPIN_CLOCK_WISE 1
#define SPIN_COUNTERCLOCK_WISE -1

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (IBAction)spinButton:(id)sender {
    [self spinLayer:_spinImage.layer duration:10 direction:SPIN_CLOCK_WISE];

}


- (void)spinLayer:(CALayer *)inLayer duration:(CFTimeInterval)inDuration
        direction:(int)direction
{
    CABasicAnimation* rotationAnimation;

    // Rotate about the z axis
    rotationAnimation =
    [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];

    // Rotate 360 degress, in direction specified
    rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI * 22.3 * direction];

    // Perform the rotation over this many seconds
    rotationAnimation.duration = inDuration;

    // Set the pacing of the animation
    rotationAnimation.timingFunction =
    [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];

    // Add animation to the layer and make it so
    [inLayer addAnimation:rotationAnimation forKey:@"rotationAnimation"];

    // Save animation
//%%%%%%%%%%  THIS IS WHERE I AM STUCK!! %%%%%%%%%
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end

If someone could just help me retain the spun image so that once the spinLayer method completes, the image stays rotated to the new spin orientation, I would greatly appreciate it. Thanks!

How to force or disable interface orientation for some but not all UIViewController?

I have an app with 9-10 screens. I embedded a UINavigationController into my view controller. I have few view controllers which I want set only portrait orientation: it means that rotating the device should not rotate these view controllers to landscape mode. I have tried the following solutions:

first:

   NSNumber *value = [NSNumber numberWithInt:UIInterfaceOrientationPortrait];
   [[UIDevice currentDevice] setValue:value forKey:@"orientation"];

but screen still rotates to landscape.

Second: I created a custom view controller class as PortraitViewController and added the code below in PortraitViewController.m

@interface PortraitViewController ()
@end

@implementation PortraitViewController
- (BOOL)shouldAutorotate
{
    return YES;
}

- (NSUInteger)supportedInterfaceOrientations
{
    //Here check class name and then return type of orientation
    return UIInterfaceOrientationMaskPortrait;
}
@end

After that I implemented PortraitViewController.h as a base class

#import <UIKit/UIKit.h>
#import "PortraitViewController.h"
@interface Login : PortraitViewController
@end

It does not work at all, still allows view controller to rotate in landscape mode.

Is there any other solution i am using iOS 8 & don't want viewcontroller to rotate in landscape mode?

EDIT: Is it possible to have Landscape orientation only for some view controllers, and force other view controllers orientation to stick to Portrait?

PFObject Subclass Not Loading Objective-C

I'm running into some trouble with a PFObject subclass. I've gone thru all of the proper setup (registering the subclass in the delegate, setting the class name, etc). But for some reason I can't get the object to load without crashing it in the view that it's supposed to be loading in.

Passing the Object

if ([segue.identifier isEqualToString:@"toPostView"])
{
    pbPostViewController *postView = [pbPostViewController new];
    postView = (pbPostViewController *)segue.destinationViewController;
    [postView setPostToLoad:_selectedPost];
}

Receiving View.h

//  Copyright (c) 2015 Chris Culos. All rights reserved.
//

#import <UIKit/UIKit.h>
#import <Parse/Parse.h>
#import "PALongTextView.h"
#import "pbPost.h"

@interface pbPostViewController : UIViewController

@property (strong, nonatomic) pbPost *postToLoad;

Receiving View.m

#import "pbPost.h"

@interface pbPostViewController ()

@end

@implementation pbPostViewController

- (void)viewDidLoad {

    pbPost *post = [pbPost postWithObject:_objectToLoad];
    NSLog(@"post: %@", post);


//    _timeStampLabel.text      = post.postTimeStamp;
    _userNameLabel.text       = [post.postOwner valueForKey:@"username"];
    _profileImage.image       = [post.postOwner valueForKey:@"profileImage"];
    _postDescriptionView.text = post.postDescriptionString;
    _bookmarkCounterLabel.text= [NSString stringWithFormat:@"%li bookmarks", post.postBookmarkedArray.count];
    _postContentView.text     = @"POST CONTENT PAGE 123 456 ETC ETC ETC";


    [super viewDidLoad];
    //

pbPost.h

@interface pbPost : PFObject <PFSubclassing>
{

}
@property (nonatomic, retain) NSDate *postTimeStamp;
@property (nonatomic, retain) NSString *postDescriptionString;
@property (nonatomic, retain) NSString *postContentString;
@property (nonatomic, retain) NSString *postBookmarkString;
@property (nonatomic, retain) NSString *postPageCounterString;
@property (nonatomic, retain) NSArray  *postBookmarkedArray;
@property (nonatomic, retain) PFFile   *postOwnerProfileImage;

@property (nonatomic, retain) NSNumber *postFontSize, *totalPages;

@property (nonatomic, retain) PFUser *postOwner;

+ (pbPost *) postWithObject: (PFObject *)object;

pbPost.m

@implementation pbPost

@dynamic postContentString, postBookmarkString, postDescriptionString, postPageCounterString, postTimeStamp, commentTableView, commentButton, bookMarkButton, postOwnerProfileImage, optionsButton, postFontSize, totalPages, postBookmarkedArray, postOwner;

+ (void)load
{
    [self registerSubclass];
}

+ (NSString *)parseClassName
{
    return @"userPosts";
}

+ (pbPost *) postWithObject: (PFObject *)object
{
//    NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
//    [dateFormat setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"];
//    [dateFormat setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"UTC"]];

    pbPost *post               = [pbPost postWithObject:object];

    [post fetchInBackgroundWithBlock:^(PFObject *object, NSError *error) {
        if (!error) {
            post.postTimeStamp         = [object valueForKey:@"createdAt"];
            post.postDescriptionString = [object valueForKey:@"titleSummary"];
            post.postFontSize          = [object valueForKey:@"fontSize"];
            post.postContentString     = [object valueForKey:@"postContent"];
            post.totalPages            = [object valueForKey:@"numPages"];
            post.postBookmarkedArray   = [object valueForKey:@"bookmarkedBy"];
            post.postOwner             = [object valueForKey:@"postOwner"];
            post.postOwnerProfileImage = [post.postOwner valueForKey:@"profileImage"];

            NSLog(@"LOAD THE THING!: %@", post);
        }
        else

        {
            NSLog(@"Error Loading Post: %@", error);
        }
    }];




    return post;
}

Under this circumstance; I'm getting an EXC_BAD_ACCESS at + (pbPost *)postWithObject:(PFObject *)object in the implementation file.

I feel like I'm missing something very simple here; what can it be? Thanks in advance for your help again everyone! This has stumped me for a little while and I need to get some outside help.

uipageview controller cannot update dot images using iOS 8?

I have created custom class with subclasss of UIPageControl

customClass.h

@interface customclass : UIPageControl
{
    UIImage* activeImage;
    UIImage* inactiveImage;
}
@property(nonatomic, retain) UIImage* activeImage;
@property(nonatomic, retain) UIImage* inactiveImage;
@property (weak, nonatomic) IBOutlet UIPageControl *pageController;

@end

customclass.m file

@implementation customclass
@synthesize activeImage,inactiveImage;
-(id)initWithCoder:(NSCoder *)aDecoder
{
    self = [super initWithCoder:aDecoder];
    if(self)
    {
       activeImage = [UIImage imageNamed:@"dots.png"];
       inactiveImage = [UIImage imageNamed:@"off.png"];


    }
    return self;
}
-(id)init
{
    self = [super init];
    if(self)
    {
        activeImage = [UIImage imageNamed:@"dots.png"];
        inactiveImage = [UIImage imageNamed:@"off.png"];

    }
    return self;
}

-(void)updateDots
{
        for (int i = 0; i < [self.subviews count]; i++)
        {
            UIImageView * dot = [self imageViewForSubview:  [self.subviews objectAtIndex: i]];
            if (i == self.currentPage) dot.image = activeImage;
            else dot.image = inactiveImage;
        }

}

- (UIImageView *) imageViewForSubview: (UIView *) view
{
    UIImageView * dot = nil;
    if ([view isKindOfClass: [UIView class]])
    {
        for (UIView* subview in view.subviews)
        {
            if ([subview isKindOfClass:[UIImageView class]])
            {
                dot = (UIImageView *)subview;
                break;
            }
        }
        if (dot == nil)
        {
            dot = [[UIImageView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 17,17)];
            [view addSubview:dot];
        }
    }
    else
    {
        dot = (UIImageView *) view;
    }

    return dot;
}


-(void)setCurrentPage:(NSInteger)page
{
    [super setCurrentPage:page];
    [self updateDots];
}

the following line never executed.I am using iOS 8.3

for (int i = 0; i < [self.subviews count]; i++)

here never get into that loop..

i dont know whats going on here..

i am following this Link

i have called at my uipageviewcontroller like this...

pageControl=[[customclass alloc]init];
    [pageControl setCurrentPage:0];

Generating Random Numbers of a certain pattern in Swift

I know that Swift can generate random numbers using this code : arc4random_uniform(50). So how can I generate random numbers in a pattern, for example : The computer should generate random numbers in the order 2,8,9,15,16,22... like any number x,x+6,x+6+1,x+6+1+6.... like that. Please help soon..! It would be a great help !

switch tab bar before navigation to another viewcontroller

I am making an iOS app where I have Tab bar + Side Menu.

Tab bar have 5 items and side menu have around 12 menus.

All side menu functionalities are from Tab 1 & side menu is accessible across all views in tab bar.

That means if I am on Tab 2, even I can access side menu. When I click on side menu item from Tab 1, I will go to Tab 1 and then navigation will occur.

What I want to do is let's say if I click on Complains menu from side menu, I want to go to ComplainsViewController.

Code I used is as below.

// go to first tab
self.tabBarController.selectedIndex = 0;
// now navigate
ComplainsViewController *sViewCon = [self.storyboard instantiateViewControllerWithIdentifier:@"Complains"];
CATransition *transition = [CATransition animation];
transition.duration = 0.5;
transition.type = kCATransitionFade;
[self.navigationController.view.layer addAnimation:transition forKey:kCATransition];
[self.navigationController pushViewController:sViewCon animated:NO];

I have two scenario.

Scenario 1 (Correct)

I am on Tab 1 and click on Complains from side menu. When I click, I go successfully to ComplainsViewController using above code.

Scenario 2 (In-Correct)

I am on Tab 2 and click on Complains from side menu. When I click, I go successfully to Tab 1, but I don't navigate to ComplainsViewController. When I click back to Tab 2, I see ComplainsViewController open in Tab 2.

Any idea how to switch first to Tab and then navigate to another viewcontroller?


Edit 1

Below is the basic structure I have.

enter image description here

Swift: 'Int' is not convertible to 'ObjCBool'

In my code I have a lazy var:

lazy var myService = {
    return JSObjection.defaultInjector().getObject(MyService) as? MyService
}()

In the same file I try to call a function of myService:

func foo() {
    myService?.getSomeStringsFrom(nil)
}

MyService is defined in an Objective-C source file:

@interface MyService : NSObject
- (NSArray *) getSomeStringsFrom:(NSString *)aString;
@end

@implementation MyService
- (NSArray *) getSomeStringsFrom:(NSString *)aString {
    return nil;
}
@end

The code cannot be compiled because the call of getSomeStringsFrom(nil) triggers an error message (twice):

<unknown>:0: error: 'Int' is not convertible to 'ObjCBool'

This does not make sense - I am doing the same with other services and XCode does not complain about it. Is it a compiler bug? I am using XCode 6.4 and Swift 1.2.

EDIT: After more digging in the code I found out that the error message can also be triggered by instantiating MyService. In the following answer, you will see the real "root" of the problem.

Why label shows previous value and current values in uitableview?

enter image description here

my code:

     -(void)btn_up_arrow:(UIButton*)click
{

    int tagvalue=[[arr_count objectAtIndex:click.tag] intValue];

    tagvalue++;
    [arr_count replaceObjectAtIndex:click.tag withObject:[NSString stringWithFormat:@"%d",tagvalue]];
       NSLog(@"increment %@",arr_count);
if(tagvalue >=5)

{


    tagvalue--;
    [arr_count replaceObjectAtIndex:click.tag withObject:[NSString stringWithFormat:@"%d",tagvalue]];
}
    label1.text=[NSString stringWithFormat:@"%d",tagvalue];

    [self.mTableView reloadInputViews];

}

i cant reload the cell in the out of tableview method. tqtableview i am used, please help me to find this problem.

String format optional parameter in swift

Ola,

I don't have to much exp with the Swift language. I want to print into a String some variables and some of them are optional.

func onRegPin(timeOut: Int64, pin: String?)->()
{
  String(format: "Timeout: %d  Pin: %@", timeOut, pin!)
}

If the pin is nil at runtime I got some assert or something. There is a way to print this optional parameters using String ?

Thanks,

What is the Swift alternative of radiansToVector and randomInRange Objective-C functions?

I watched an old ios 7 spritekit course and they use these methods. I tried to use them in Swift, but they didn't work. What should I use instead?

static inline CGVector radiansToVector(CGFloat radians) {
    CGVector vector;
    vector.dx = cosf(radians);
    vector.dy = sinf(radians);
    return vector;
}

static inline CGFloat randomInRange(CGFloat low, CGFloat high) {
    CGFloat value = arc4random_uniform(UINT32_MAX) / (CGFloat)UINT32_MAX;
    return value * (high - low) + low;
}

Objective-C: What does getter= actually do in @property?

This code:

@interface SomeClass : NSObject

@property(getter=myProp) NSString *prop;

@end

@implementation AnotherClass

- (void)test {
    SomeClass *s = [[SomeClass alloc] init];
    NSString *x = s.prop;
    NSString *y = s.myProp;
}

@end

Both x and y are the value of the same property, I got two getters, one is -myProp and the other is -prop, so does declaring getter add another getter besides the auto-generated getter?

If this is right, can I use getter= to generate more than one getter?

Also, how do I remove the auto-generated -prop getter?

Can't pass parameter of type CGColorRef in LLDB

I'm extending Facebook’s Chisel to be able to visualize a color from the debugger. I want it to work for UIColor, CIColor, and CGColorRef. The two object-based ones are working fine, but the CGColorRef is giving me trouble.

Here is the bug I'm working from, where I've already hashed out a bunch of the stuff from this question.

I've boiled the issue down to this test case:

If I have some function:

+ (UIColor *)someColor {
    UIColor *uiColor = [UIColor redColor];
    CGColorRef cgColor = uiColor.CGColor;
    UIColor *newUIColor = [UIColor colorWithCGColor:cgColor];
    return newUIColor;
}

And I set a breakpoint on the return newUIColor; line, this is what happens in LLDB:

(lldb) po cgColor
<CGColor 0x7f992b626710> [<CGColorSpace 0x7f992b70d5b0> (kCGColorSpaceDeviceRGB)] ( 0 0.478431 1 1 )

(lldb) po [UIColor colorWithCGColor:cgColor]
error: cannot initialize a parameter of type 'CGColor *' with an lvalue of type 'CGColorRef' (aka 'CGColor *')
error: 1 errors parsing expression
(lldb) po [UIColor colorWithCGColor:(CGColorRef)cgColor]
error: cannot initialize a parameter of type 'CGColor *' with an rvalue of type 'CGColorRef' (aka 'CGColor *')
error: 1 errors parsing expression
(lldb) po [UIColor colorWithCGColor:(id)cgColor]
error: cannot initialize a parameter of type 'CGColor *' with an rvalue of type 'id'
error: 1 errors parsing expression
(lldb) po [UIColor colorWithCGColor:(CGColor *)cgColor]
error: use of undeclared identifier 'CGColor'
error: expected expression
error: 2 errors parsing expression
(lldb) expr @import CoreGraphics
(lldb) po [UIColor colorWithCGColor:(CGColorRef)cgColor]
error: cannot initialize a parameter of type 'CGColor *' with an rvalue of type 'CGColorRef' (aka 'CGColor *')
error: 1 errors parsing expression
(lldb) po [UIColor colorWithCGColor:(CGColor *)cgColor]
error: cannot initialize a parameter of type 'CGColor *' with an rvalue of type 'CGColor *'
error: 1 errors parsing expression
(lldb) po [UIColor colorWithCGColor:(struct CGColor *)cgColor]
error: cannot initialize a parameter of type 'CGColor *' with an rvalue of type 'struct CGColor *'
error: 1 errors parsing expression

So, how can I get lldb to execute a line that takes a parameter of type CGColorRef?

EAAccessoryManager connectedAccessories returns empty array

I am using EAAccessoryManager to connect my application to a MFI accessory. During the initial connection, in bluetooth setting screen, it showing as device connected. When i try to get the list of connected device using "[accessoryManager connectedAccessories]", it returns a empty array. But when i use "showBluetoothAccessoryPickerWithNameFilter", it shows me the accessory in the list. The problem is i don't want user to choose the accessory. I want to make this a automated process. I have included the accessory protocol string in info.plist too. Please guide me with this issue. What mistake i am doing here ?

Swift possible to add view under navigation bar in UITableViewController

I wonder if its possible to add a view under the navigation bar in a UITableViewController?

What I would like to do is to add a view under the navigation bar in my UITableViewController so that I can add a search input / filter button to that view. But I want the view to have a fixed position under the navigation bar so that I can hide the navigationbar+view when swiping.

Right now storyboard only lets me add a view in the UITableViewController. And the new view is also swipeable. And the loading indicator shows up above the view when you swipe down.

enter image description here

Different coordinates while resizing an imageview iOS

I'm trying to resizing an imageview using these functions:

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
    UITouch* mTouch = [touches anyObject];
    if (mTouch.view == [self Logo_01]) {
        CGPoint cp = [mTouch locationInView:[self view]];
        [[mTouch view]setCenter:CGPointMake(cp.x-xd, cp.y-yd)];
        NSLog(@"questo è x");
        NSLog(@"lalal %f", cp.y);

        if (cp.y > 390) {

            [_Logo_01 setHidden:YES];
        }
        if (cp.y < 130) {
            [_Logo_01 setHidden:YES];
        }
        if (cp.x > 290) {
            [_Logo_01 setHidden:YES];
        }
        if (cp.x < 40) {
            [_Logo_01 setHidden:YES];
        }

    }

when i resize my Logo on the app the image resizes correctly but my center point is wrong

ld: 14 duplicate symbols for architecture x86_64 clang: error: linker command failed with exit code 1 in iOS PayPal sdk integration

I am new in iOS, so please help ** i already add all framework and sdk of paypal. i also checked duplication of linkes** how to solve this error. thanks in advance

Ld /Users/alivenetsolution/Library/Developer/Xcode/DerivedData/DreamPartner-cvamdjxxcqqfirfztpoultvwmoox/Build/Intermediates/DreamPartner.build/Debug-iphonesimulator/DreamPartner.build/Objects-normal/x86_64/DreamPartner normal x86_64

cd "/Users/alivenetsolution/Desktop/@16 july/DreamPartner"
export IPHONEOS_DEPLOYMENT_TARGET=8.4
export PATH="/Applications/http://ift.tt/1eHqHUg"
/Applications/http://ift.tt/1jmLxI7 -arch x86_64 -isysroot /Applications/http://ift.tt/1O1bH15 -L/Users/alivenetsolution/Library/Developer/Xcode/DerivedData/DreamPartner-cvamdjxxcqqfirfztpoultvwmoox/Build/Products/Debug-iphonesimulator -L/Users/alivenetsolution/Desktop/@16\ july/DreamPartner/DreamPartner/ThirdParty/PayPalMobile -F/Users/alivenetsolution/Library/Developer/Xcode/DerivedData/DreamPartner-cvamdjxxcqqfirfztpoultvwmoox/Build/Products/Debug-iphonesimulator -F/Users/alivenetsolution/Downloads/StripeiOS-WithoutApplePay -filelist /Users/alivenetsolution/Library/Developer/Xcode/DerivedData/DreamPartner-cvamdjxxcqqfirfztpoultvwmoox/Build/Intermediates/DreamPartner.build/Debug-iphonesimulator/DreamPartner.build/Objects-normal/x86_64/DreamPartner.LinkFileList -Xlinker -objc_abi_version -Xlinker 2 -lc++ -ObjC -fobjc-arc -fobjc-link-runtime -Xlinker -no_implicit_dylibs -mios-simulator-version-min=8.4 -Xlinker -sectcreate -Xlinker __TEXT -Xlinker __entitlements -Xlinker /Users/alivenetsolution/Library/Developer/Xcode/DerivedData/DreamPartner-cvamdjxxcqqfirfztpoultvwmoox/Build/Intermediates/DreamPartner.build/Debug-iphonesimulator/DreamPartner.build/DreamPartner.app.xcent -framework MessageUI -lPayPalMobile -framework SystemConfiguration -framework MobileCoreServices -framework CoreMedia -framework AudioToolbox -framework AVFoundation -framework OpenGLES -lxml2 -framework PassKit -framework CoreText -framework MapKit -framework CoreLocation -framework Stripe -framework Security -framework UIKit -framework Social -framework QuartzCore -framework CoreFoundation -framework CoreGraphics -framework CoreData -framework AddressBook -framework Accounts -Xlinker -dependency_info -Xlinker /Users/alivenetsolution/Library/Developer/Xcode/DerivedData/DreamPartner-cvamdjxxcqqfirfztpoultvwmoox/Build/Intermediates/DreamPartner.build/Debug-iphonesimulator/DreamPartner.build/Objects-normal/x86_64/DreamPartner_dependency_info.dat -o /Users/alivenetsolution/Library/Developer/Xcode/DerivedData/DreamPartner-cvamdjxxcqqfirfztpoultvwmoox/Build/Intermediates/DreamPartner.build/Debug-iphonesimulator/DreamPartner.build/Objects-normal/x86_64/DreamPartner

duplicate symbol _kPayPalOAuth2ScopeFuturePayments in: /Users/alivenetsolution/Library/Developer/Xcode/DerivedData/DreamPartner-cvamdjxxcqqfirfztpoultvwmoox/Build/Intermediates/DreamPartner.build/Debug-iphonesimulator/DreamPartner.build/Objects-normal/x86_64/PackageViewController.o /Users/alivenetsolution/Library/Developer/Xcode/DerivedData/DreamPartner-cvamdjxxcqqfirfztpoultvwmoox/Build/Intermediates/DreamPartner.build/Debug-iphonesimulator/DreamPartner.build/Objects-normal/x86_64/AppDelegate.o duplicate symbol _kPayPalOAuth2ScopeProfile in: /Users/alivenetsolution/Library/Developer/Xcode/DerivedData/DreamPartner-cvamdjxxcqqfirfztpoultvwmoox/Build/Intermediates/DreamPartner.build/Debug-iphonesimulator/DreamPartner.build/Objects-normal/x86_64/PackageViewController.o /Users/alivenetsolution/Library/Developer/Xcode/DerivedData/DreamPartner-cvamdjxxcqqfirfztpoultvwmoox/Build/Intermediates/DreamPartner.build/Debug-iphonesimulator/DreamPartner.build/Objects-normal/x86_64/AppDelegate.o duplicate symbol _kPayPalOAuth2ScopeOpenId in: /Users/alivenetsolution/Library/Developer/Xcode/DerivedData/DreamPartner-cvamdjxxcqqfirfztpoultvwmoox/Build/Intermediates/DreamPartner.build/Debug-iphonesimulator/DreamPartner.build/Objects-normal/x86_64/PackageViewController.o /Users/alivenetsolution/Library/Developer/Xcode/DerivedData/DreamPartner-cvamdjxxcqqfirfztpoultvwmoox/Build/Intermediates/DreamPartner.build/Debug-iphonesimulator/DreamPartner.build/Objects-normal/x86_64/AppDelegate.o duplicate symbol _kPayPalOAuth2ScopePayPalAttributes in: /Users/alivenetsolution/Library/Developer/Xcode/DerivedData/DreamPartner-cvamdjxxcqqfirfztpoultvwmoox/Build/Intermediates/DreamPartner.build/Debug-iphonesimulator/DreamPartner.build/Objects-normal/x86_64/PackageViewController.o /Users/alivenetsolution/Library/Developer/Xcode/DerivedData/DreamPartner-cvamdjxxcqqfirfztpoultvwmoox/Build/Intermediates/DreamPartner.build/Debug-iphonesimulator/DreamPartner.build/Objects-normal/x86_64/AppDelegate.o duplicate symbol _kPayPalOAuth2ScopeEmail in: /Users/alivenetsolution/Library/Developer/Xcode/DerivedData/DreamPartner-cvamdjxxcqqfirfztpoultvwmoox/Build/Intermediates/DreamPartner.build/Debug-iphonesimulator/DreamPartner.build/Objects-normal/x86_64/PackageViewController.o /Users/alivenetsolution/Library/Developer/Xcode/DerivedData/DreamPartner-cvamdjxxcqqfirfztpoultvwmoox/Build/Intermediates/DreamPartner.build/Debug-iphonesimulator/DreamPartner.build/Objects-normal/x86_64/AppDelegate.o duplicate symbol _kPayPalOAuth2ScopeAddress in: /Users/alivenetsolution/Library/Developer/Xcode/DerivedData/DreamPartner-cvamdjxxcqqfirfztpoultvwmoox/Build/Intermediates/DreamPartner.build/Debug-iphonesimulator/DreamPartner.build/Objects-normal/x86_64/PackageViewController.o /Users/alivenetsolution/Library/Developer/Xcode/DerivedData/DreamPartner-cvamdjxxcqqfirfztpoultvwmoox/Build/Intermediates/DreamPartner.build/Debug-iphonesimulator/DreamPartner.build/Objects-normal/x86_64/AppDelegate.o duplicate symbol _kPayPalOAuth2ScopePhone in: /Users/alivenetsolution/Library/Developer/Xcode/DerivedData/DreamPartner-cvamdjxxcqqfirfztpoultvwmoox/Build/Intermediates/DreamPartner.build/Debug-iphonesimulator/DreamPartner.build/Objects-normal/x86_64/PackageViewController.o /Users/alivenetsolution/Library/Developer/Xcode/DerivedData/DreamPartner-cvamdjxxcqqfirfztpoultvwmoox/Build/Intermediates/DreamPartner.build/Debug-iphonesimulator/DreamPartner.build/Objects-normal/x86_64/AppDelegate.o duplicate symbol _kPayPalOAuth2ScopeAddress in: /Users/alivenetsolution/Library/Developer/Xcode/DerivedData/DreamPartner-cvamdjxxcqqfirfztpoultvwmoox/Build/Intermediates/DreamPartner.build/Debug-iphonesimulator/DreamPartner.build/Objects-normal/x86_64/PackageViewController.o /Users/alivenetsolution/Desktop/@16 july/DreamPartner/DreamPartner/ThirdParty/PayPalMobile/libPayPalMobile.a(PPAuthNAuthScopes.o) duplicate symbol _kPayPalOAuth2ScopeEmail in: /Users/alivenetsolution/Library/Developer/Xcode/DerivedData/DreamPartner-cvamdjxxcqqfirfztpoultvwmoox/Build/Intermediates/DreamPartner.build/Debug-iphonesimulator/DreamPartner.build/Objects-normal/x86_64/PackageViewController.o /Users/alivenetsolution/Desktop/@16 july/DreamPartner/DreamPartner/ThirdParty/PayPalMobile/libPayPalMobile.a(PPAuthNAuthScopes.o) duplicate symbol _kPayPalOAuth2ScopeFuturePayments in: /Users/alivenetsolution/Library/Developer/Xcode/DerivedData/DreamPartner-cvamdjxxcqqfirfztpoultvwmoox/Build/Intermediates/DreamPartner.build/Debug-iphonesimulator/DreamPartner.build/Objects-normal/x86_64/PackageViewController.o /Users/alivenetsolution/Desktop/@16 july/DreamPartner/DreamPartner/ThirdParty/PayPalMobile/libPayPalMobile.a(PPAuthNAuthScopes.o) duplicate symbol _kPayPalOAuth2ScopeOpenId in: /Users/alivenetsolution/Library/Developer/Xcode/DerivedData/DreamPartner-cvamdjxxcqqfirfztpoultvwmoox/Build/Intermediates/DreamPartner.build/Debug-iphonesimulator/DreamPartner.build/Objects-normal/x86_64/PackageViewController.o /Users/alivenetsolution/Desktop/@16 july/DreamPartner/DreamPartner/ThirdParty/PayPalMobile/libPayPalMobile.a(PPAuthNAuthScopes.o) duplicate symbol _kPayPalOAuth2ScopePayPalAttributes in: /Users/alivenetsolution/Library/Developer/Xcode/DerivedData/DreamPartner-cvamdjxxcqqfirfztpoultvwmoox/Build/Intermediates/DreamPartner.build/Debug-iphonesimulator/DreamPartner.build/Objects-normal/x86_64/PackageViewController.o /Users/alivenetsolution/Desktop/@16 july/DreamPartner/DreamPartner/ThirdParty/PayPalMobile/libPayPalMobile.a(PPAuthNAuthScopes.o) duplicate symbol _kPayPalOAuth2ScopePhone in: /Users/alivenetsolution/Library/Developer/Xcode/DerivedData/DreamPartner-cvamdjxxcqqfirfztpoultvwmoox/Build/Intermediates/DreamPartner.build/Debug-iphonesimulator/DreamPartner.build/Objects-normal/x86_64/PackageViewController.o /Users/alivenetsolution/Desktop/@16 july/DreamPartner/DreamPartner/ThirdParty/PayPalMobile/libPayPalMobile.a(PPAuthNAuthScopes.o) duplicate symbol _kPayPalOAuth2ScopeProfile in: /Users/alivenetsolution/Library/Developer/Xcode/DerivedData/DreamPartner-cvamdjxxcqqfirfztpoultvwmoox/Build/Intermediates/DreamPartner.build/Debug-iphonesimulator/DreamPartner.build/Objects-normal/x86_64/PackageViewController.o /Users/alivenetsolution/Desktop/@16 july/DreamPartner/DreamPartner/ThirdParty/PayPalMobile/libPayPalMobile.a(PPAuthNAuthScopes.o) ld: 14 duplicate symbols for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) ##

How to fill draw a line on UIBezierPath using UIBezierPath

I am working on shapes app.My app is like this. I have different shapes(Triangle,square,circle..) with lines. (See attached image).

I have to fill out lines my drawing.

Sample Image

I draw a image by using

   UIBezierPath* aShape;
    aShape = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0,0,rect.size.width,rect.size.height) cornerRadius:1.0];
    [[UIColor whiteColor] setStroke];
    [[UIColor blueColor] setFill]; 
    aShape.lineWidth = 30;
    [aShape fill];
    [aShape stroke];

So the result is

Result Image

I added the code to draw a line as

 - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    UITouch *touch = [touches anyObject];
    CGPoint p = [touch locationInView:self];
    [path moveToPoint:p];
}

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
     UITouch *touch = [touches anyObject];
    CGPoint p = [touch locationInView:self];

    UIBezierPath *tempPath = [self tapTargetForPath:aShape];
    [path addLineToPoint:p]; // (4)
    [self setNeedsDisplay];

}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
   {
      [self touchesMoved:touches withEvent:event];
  }

Give any trick to achieve this. The result should be like this. Result Image

Wrap image in possible in ios which funcation are used in ios

1)Drag an image (from below or from disk) to the right -->gallary in selected image in view

2)Add at least 3 points and drag.

it is possible[![enter image description here][1]][1]

Only one corner is getting rounded in UITextField

I am using the following code to make UITextField's Top corners rounded, but the problem is only left top corner is getting rounded. What I am doing wrong or is there any other way to do so.

- (void)roundCornersOnView:(UIView*)view onTopLeft:(BOOL)tl topRight:(BOOL)tr bottomLeft:(BOOL)bl bottomRight:(BOOL)br radius:(float)radius
{

    if (tl || tr || bl || br) {
        UIRectCorner corner = 0; //holds the corner
        //Determine which corner(s) should be changed
        if (tl) {
            corner = corner | UIRectCornerTopLeft;
        }
        if (tr) {
            corner = corner | UIRectCornerTopRight;
        }
        if (bl) {
            corner = corner | UIRectCornerBottomLeft;
        }
        if (br) {
            corner = corner | UIRectCornerBottomRight;
        }

        UIView* roundedView = view;
        UIBezierPath* maskPath = [UIBezierPath bezierPathWithRoundedRect:roundedView.bounds byRoundingCorners:corner cornerRadii:CGSizeMake(radius, radius)];
        CAShapeLayer* maskLayer = [CAShapeLayer layer];
        maskLayer.frame = roundedView.bounds;
        maskLayer.path = maskPath.CGPath;
        roundedView.layer.mask = maskLayer;
    }
}

Calling the above method

[self roundCornersOnView:textField onTopLeft:YES topRight:YES bottomLeft:NO bottomRight:NO radius:5.0];

Why doesn't creating a new cocoa class import cocoa?

When I create a new Cocoa class in Xcode 6 why doesn't it import Cocoa since it's called "Cocoa class"? I know Cocoa uses Foundation but there are also things in Cocoa which are not in Foundation such as NSTableView and others. Thanks.

CollectionView inside a Table View

(Sorry I couldn't add image since I don't have sufficient reputation points)

I want to Include one text label with large text (around 10-15 lines) and two collection views in a table view. This is my home view controller on login.Also other button and title label are as shown in image. Both collection views are horizontally scrollable and table view containing all these is vertically scrollable.Further each collection view cell has some data with fields that are populated at runtime from web service calls. As shown in image attached. Requirements - Xcode 6, should be using storyboard (no xib, no coding only), objective c only, iPad only.

accessing the setMethod of a @property in ios

after many hour of tutorials and googling i knew that when we define a property inside the header file the compiler automatically generate the setters and getters here is an example:
"example.h"

@property(strong,nonatomic) NSNumber *test;

example.m

[self.test setTest [@"3"]];

so what i want is to access this method to check the method declaration and here is the reason that i want

Full Scenario

@interface exampleController ()  
{

    int example;
}

// here is a instance variable used to save a value while the app running i am getting this value from a dictionary and then save the value of the example variable to the core data

here is the entity class

exampleEntity.h

 @property(strong,nonatomic) NSNumber *example;

exampleEntity.m

@dynamic example;

// since the instance variable is int we need to cast it to NSNumber so i follow this link

[entry setExample : [NSNumber numberWithInt:example]];

Finally after running this code i go into this exception:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException'

Full Code

    #import "viewController.h"
    @interface viewController ()  
   {

         int example;
    }


- (void)viewDidLoad {
gettingTheExampleValueFromDictionary();
}



-(void)gettingTheExampleValueFromDictionary()


 {

                NSDictionary *dictionary = [NSJSONSerialization    JSONObjectWithData:requestHandler options:0 error:&jsonParsingError];
       example = [[dictionary objectForKey:@"exampleId"] intValue];


 }



- (IBAction)doneButton:(id)sender {

  [self insertDataToCoreData];
  [self dismissSelf];
}

      -(void)insertDataToCoreData   {

   CoreData *coreDataStack = [CoreData defaultStack];
        ExampleEntity *entry = [NSEntityDescription insertNewObjectForEntityForName:
                                    @"ExampleEntity" inManagedObjectContext:coreDataStack.managedObjectContext];

            [entry setExample :[NSNumber numberWithInt:example]];
// here we go into the error //



    [coreDataStack saveContext];
    }





  @end
// and if you ask me for entity class here is:

 #import <Foundation/Foundation.h>
 @interface ReservationEntity : NSObject
 @property (nonatomic,strong) NSNumber *example;
   @end



 #import "exampleEntity.h"
 @implementation exampleEntity
 @dynamic example;
 @end
 // and if you ask me for core data here is the pic needed //

core data

   // the configuration of xcdatamodel

configuration of xcdatamodel

IOS-9 UIStackView issue in scrolling to leading edge

I am trying to implement scroll for UIStackView where there are two buttons to add and delete views horizontally. I am changing the scroll.contentSize as the size of UIStackView so when the stack size is greater than the ScrollView's size, stack view can be scrolled. But while scrolling I am not able to reach to the starting of stack view. Few of my views in the beginning can't be reached while scrolling but last views can be reached.

//In load view
        scroll = [[UIScrollView alloc]initWithFrame:CGRectMake(25,100, screen.size.width-50, 50)];
        scroll.backgroundColor = [UIColor whiteColor];
        [self.view addSubview:scroll];
        scroll.scrollEnabled = YES;
        scroll.delegate = self;
        cus.center = CGPointMake(scroll.frame.size.width/2, scroll.frame.size.height/2);
        [scroll addSubview:cus];

        stack = [[UIStackView alloc]init];
        stack.axis = UILayoutConstraintAxisHorizontal;
        stack.distribution = UIStackViewDistributionEqualSpacing;
        stack.spacing = 30;
        stack.alignment = UIStackViewAlignmentLeading;
        stack.translatesAutoresizingMaskIntoConstraints = NO;
        [scroll addSubview:stack];


       [stack.centerXAnchor constraintEqualToAnchor:scroll.centerXAnchor].active = YES;
       [stack.centerYAnchor constraintEqualToAnchor:scroll.centerYAnchor].active = YES;

        a = 0;//this is used to count no of views currently present
//Completion of load view

    -(void)addOn//Action performing when clicking on add button.
    {

            UIView *vampire = [[UIView alloc]init];
            vampire.backgroundColor = [UIColor blackColor];
            [vampire.widthAnchor constraintEqualToConstant:40].active = YES;
            [vampire.heightAnchor constraintEqualToConstant:40].active = YES;
            vampire.layer.cornerRadius = 20;
            a = (int)stack.subviews.count;
            [stack addArrangedSubview:vampire];
            float contentWidth = ((a-1)*30+(a*40));
            scroll.contentSize = CGSizeMake(contentWidth,vampire.frame.size.height);
    }


    -(void)removeOn//Action performing when clicking on remove button.
    {
        if(a >=0)
        {
            remove.userInteractionEnabled = NO;
        UIView *view = stack.arrangedSubviews[a];
        [UIView animateWithDuration:.2
                              delay:0
                            options:UIViewAnimationOptionCurveEaseInOut
                         animations:^{
                             view.hidden = YES;

                         } completion:^(BOOL finished) {
                              a--;
                             [view removeFromSuperview];
                             float contentWidth = ((a-1)*30+(a*40));
                             scroll.contentSize = CGSizeMake(contentWidth,view.frame.size.height);
                             remove.userInteractionEnabled = YES;
                         }];
                   }
    }

Here is the image where I can't scroll to my first views Here is the image where I can scroll to my last views

Thanks in advance.

UICollectionView crashing on insertSections, with endItemAnimationsWithInvalidationContext:tentativelyForReordering:

I'm trying to add a new section to my collection view, as a new section's worth of data is added to the data source. I'm doing it like this:

self.conversationCollectionView.performBatchUpdates({
    self.conversationCollectionView.insertSections(NSIndexSet(index: 0))
}, completion: {
(finished: Bool) -> Void in
})

I started by not using performBatchUpdates, too. Either way, I get this crash, every time:

Assertion failure in -[MyApp _endItemAnimationsWithInvalidationContext:tentativelyForReordering:]

This is after running the line insertSections.

I have more than 0 indexes. I've tried changing that index number to other values, including the correct value. I get the same crash, every time. It doesn't seem to be an 'out of bounds' kind of error. I'm not sure what it is.

How to scroll the textfields when view is moved up?

I have text fields on registration screen so when keyboard appears i am moving up the view up.Now i want to scroll through text fields when i my view is moved up.

code for moving view up:

         CGRect rect = self.view.frame;
         rect.origin.y += 220;
         rect.size.height -= 220;
         self.view.frame = rect;

Here is hirecrchy

I have UIScrollView at top then under UIScrollView i have UIView i call it as contentView.On the contentView i have added some text fields.So my parent view is moved up fine but i am not able to scroll the textFields up & down when i view is up. I set the following value for scrolling.

    self.cvHeight.constant=500;
    self.scrollView.contentSize=CGSizeMake(500, 500);

Here cvHeight is outlet of height constraint of the contentView & scrollView is outlet of UIScrollView

Edit: When i am not moving the parentView up which is self.view then i am able to scroll through but if i move the parent view up then my textFields are not scrolling down they are just moving up.

invalid nib registered for identifier (DeviceLostPhotoCell) - nib must contain exactly one top level object which must be a UITableViewCell instance

I'm trying to create a custom cell for my table. This custom cell must have a collection horizontal view inside. I did the configuration of the collection view with the delegate and datasource and add the necessary methods. Now I am getting the following error:

"reason: 'invalid nib registered for identifier (DeviceLostPhotoCell) - nib must contain exactly one top level object which must be a UITableViewCell instance'"

this is my code:

- (void)awakeFromNib {
    self.collectionView.delegate = self;
    self.collectionView.dataSource = self;
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section; {
    return 5;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath;{
    UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"DeviceImageCell" forIndexPath:indexPath];

    return cell;
}

this red square this with the identifier "DeviceImageCell" what should be the cell of my collection view.

this red square this with the identifier "DeviceImageCell" what should be the cell of my collection view.

ios: NSInvalidArgumentException, unrecognised selector on prepareForSegue

The situation:

I've got three views named LogInView, CategoryRegistrationView, and BlueToothCheckerView. Both LogInView and CategoryRegistrationView can segue to BlueToothCheckerView.

BlueToothCheckerView itself can segue into two different views, depending on a string set by LogInView or CategoryRegistrationView.

LogInView does this just fine. A user can log in from LogInView, check if his Bluetooth connection is on in BlueToothCheckerView, and is then redirected to a view he won't see if he otherwise came in from CategoryRegistrationView.

CategoryRegistrationView has problems.

The Problem:

On click of the button to take me to BlueToothView, this error appears:

[BlueToothCheckerViewController setFromSegue:]: unrecognized selector sent to instance 0x7f8c935a4f80

A lot of posts online indicated that it's because BlueToothCheckerView is not set as the Custom Class for xib BlueToothView, but it is.

The Code (We'll be focusing on CategoryRegistrationView and BlueToothCheckerView to keep things short):

CategoryRegistrationViewController.h - Problem segment:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
    NSLog(@"Segue Identifier: %@", [segue identifier]);

    if ([[segue identifier] isEqualToString:@"CategoryRegistrationToBlueToothCheckerSegue"]) {
        BlueToothCheckerView *btcv = [segue destinationViewController];
        btcv.fromSegue = @"CategoryRegistrationToBlueToothCheckerSegue"; // <-- Error here
        NSLog(@"Something wrong here");
    }
}

Note: LogInViewController has the exact same code, with btvc.fromSegue set to "LoginToBlueToothCheckerSegue" instead.

BlueToothCheckerView.h

#import <UIKit/UIKit.h>

@protocol BlueToothCheckerViewDelegate <NSObject>

@required
- (void)turnOnBlueToothPressed:(id)sender;
- (void)skipPressed:(id)sender;
@end

@interface BlueToothCheckerView : UIView

@property (weak, nonatomic) id<BlueToothCheckerViewDelegate> delegate;

@property (weak, nonatomic) IBOutlet UIButton *TurnOnBlueToothButton;
@property (weak, nonatomic) IBOutlet UIButton *SkipButton;
@property (weak, nonatomic) IBOutlet UIImageView *blueToothImage;

@property (nonatomic) NSString* fromSegue;

- (IBAction)turnOnBlueToothPressed:(id)sender;
- (IBAction)skipPressed:(id)sender;

@end

BlueToothCheckerViewController.h

#import "BaseUIViewController.h"
#import "BlueToothCheckerView.h"
#import "Constants.h"
#import <CoreBluetooth/CoreBluetooth.h>

@interface BlueToothCheckerViewController : BaseUIViewController <BlueToothCheckerViewDelegate,CBCentralManagerDelegate>

@property (weak, nonatomic) BlueToothCheckerView *btcv;

@end

Both BlueToothCheckerView and BlueToothCheckerViewController at the very least show string fromSegue.

Here's a sample of how fromSegue is used, in BlueToothCheckerViewController.m:

- (void)skipPressed:(id)sender {
    NSLog(@"Bluetooth already on");

    if ([self.btcv.fromSegue isEqual: @"LoginToBlueToothCheckerSegue"]){
        [self performSegueWithIdentifier:@"BlueToothCheckerToDashboardSegue" sender:self];
    }
    else if ([self.btcv.fromSegue isEqual: @"CategoryRegistrationToBlueToothCheckerSegue"]){
        [self performSegueWithIdentifier:@"BlueToothCheckerToWalkthroughSegue" sender:self];
    }
}

What I Tried:

I tried deleting the segue in question, and re-adding it. It didn't much. I also commented out the line btcv.fromSegue = @"CategoryRegistrationToBlueToothCheckerSegue";, and confirmed the program ran fine without it.

I also tried adding a cast to BlueToothCheckerController. Didn't work either.

Any thoughts, please?

How to get the folder details for a mail using messageID?

I am using Mailcore2 to fetch mails from IMAP server. If I have a messageID of a mail using that can I get the folder in which it is for Outlook and Yahoo mails? Thanks for any help.

iOS spotlight icon won't show

For my app icon I have crossed Iphone: iOS 8 and later and iOS 7 and later and ipad: iOS 7 and later then I transferred all 12 icons but when I do a spotlight search in my iphone the icon won't show up. Have I missed something?

Also, what does iOS icon is pre-renered option mean and do I need it?

Thanks

iOS how to stop audio playing in background?

In my app i'm playing live audio stream, audio also continue playing in background, for this i'm using

// Set AVAudioSession
    NSError *sessionError = nil;
    // [[AVAudioSession sharedInstance] setDelegate:self];
    [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord error:&sessionError];

    // Change the default output audio route
    UInt32 doChangeDefaultRoute = 1;
 AudioSessionSetProperty(kAudioSessionProperty_OverrideCategoryDefaultToSpeaker, sizeof(doChangeDefaultRoute), &doChangeDefaultRoute);
    self.player = [[AVQueuePlayer alloc] initWithURL:[NSURL URLWithString:streamingUrl]];
    self.player.actionAtItemEnd = AVPlayerActionAtItemEndNone;

I'm able to play audio in background/foreground. The streaming url sends audio continuously and my app play audio continuously in background, but at a certain time i want to stop audio player. So my question is how to stop audio player if my app is running in background (playing in background)?

navigation controller pushViewController not working

I'm creating an application that has 2 main view controllers at the moment. The app loads into the initial viewController, and clicking a button inside should bring up the second viewController. Here's what I have:

AppDelegate.h

#import <UIKit/UIKit.h>
#import "ViewController1.h"

@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) ViewController1 *mainViewCtr;
@property (strong, nonatomic) UINavigationController *navigationController;
@end

AppDelegate.m

- (void)applicationDidFinishLaunching:(UIApplication *)application {
    _mainViewCtr = [[ViewController1 alloc] initWithNibName:@"mainViewCtr" bundle:nil];
    _navigationController = [[UINavigationController alloc] initWithRootViewController:_mainViewCtr];
    _window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    _window.rootViewController = _navigationController;
    _navigationController.delegate = self;
    _navigationController.navigationBarHidden = YES;
    [_window addSubview:_navigationController.view];
    [self.window makeKeyAndVisible];
}

and my button method inside viewcontroller1:

- (IBAction)SessionNickNameSubmit:(id)sender {
    ViewController2 *secondViewCtrl = [[ViewController2 alloc] initWithNibName:@"secondViewCtrl" bundle:nil];

    [self.navigationController pushViewController:secondViewCtrl animated:YES];
}

but when I click the button the view doesn't change. I tried debugging and the code is hit, but nothing happens.

am I missing a setting somewhere?

UPDATE

I've updated all viewController variable names:

instead of ViewController1/2 I'm using mainViewCtrl and secondViewCtrl

but still no use :(

Undefined symbols for architecture x86_64 on Xcode 6.3

I'am finalising an Open Source C coded CometD library, i thought it would be a good idea to open it to OSX/iOS users, like myself.

In order to ease up the work for OSX/iOS developers i wanted to switch from a static C library to a Xcode iOS Static Libary. So i followed advices found on the net, and generated a static iOS compatible library.

The problem is that, each time i try to use it i get an of type :

Undefined symbols for architecture x86_64: ******, referenced from: -********** in *******.a(*******.o)

This error get repeated for almost every C function that i have in my library.

First i though maybe the library is not x86_64 compatible, empty, or really doesn't have any x86_64 symbol in it.

So i checked with a "lipo -info" on the library and here is the answer :

enter image description here

To really be sure i also used "nm -arch x86_64" on the library, and went fetching for several undefined functions reported by Xcode as errors. I thought i will be wrong and find nothing but guess what ? I found the symbols : enter image description here

enter image description here

So my question is :

If the symbols are present in a x86_64 compatible library, why is Xcode prompting this error ? Even if i compile the library for all arm*/s types i still get this x86_64 error.

Am i unaware of something or am i just doing it wrong ?

Your answers are always appreciated.

App auto renewals in app subscriptions

Is there a way to get the application renewals for in app subscription.

I have in app subscription inside my app i wan't to count the number that the user renew the in app subscriptions (Purchase).

(In app subscription history inside application).

How to show search results with UISearchResultsUpdating in the new iOS8 Objective-C

I've been reading a lot about the new UISearchController and its protocols. and I saw many pages in the documentation also the sample code from Apple. But I couldn't implement it in my project -Xcode 6.4- iOS App.

Right now I need help on implementing the UISearchResultsUpdating protocol. I've this TableViewController "FYPBooksLibraryTableViewController.h" and I want to search its file names. when I run it every thing works, BUT the results are not shown at all.

From .m file:

#pragma mark - UISearchBarDelegate
- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar {
    [searchBar resignFirstResponder];
}

#pragma mark - UISearchControllerDelegate
- (void)presentSearchController:(UISearchController *)searchController {
}

- (void)willPresentSearchController:(UISearchController *)searchController {
}

- (void)didPresentSearchController:(UISearchController *)searchController {
}

- (void)willDismissSearchController:(UISearchController *)searchController {
}

- (void)didDismissSearchController:(UISearchController *)searchController {
}

#pragma mark - UISearchResultsUpdating
- (void)updateSearchResultsForSearchController:(UISearchController *)searchController {
//Waiting a fix
}

My data are in those 2 files: BooksData & FYPBooksObject

    //  BooksData.h

    #import <Foundation/Foundation.h>

    #define BOOK_NAME @"Book Name"
    #define BOOK_NUMBER_OF_PAGES @"Number of Pages"
    #define BOOK_LINK @"Book Path"

    @interface BooksData : NSObject
    + (NSArray *)allBooks;
    @end

    //  BooksData.m
    #import "BooksData.h"

    @implementation BooksData
    + (NSArray *)allBooks {
        NSMutableArray *booksInformation = [@[] mutableCopy];
        NSDictionary *book1Dictionary = @{BOOK_NAME : @"Book 1", BOOK_NUMBER_OF_PAGES : @"Number of pages: 43", BOOK_LINK : @"http://ift.tt/1ClMoQJ"};
        [booksInformation addObject:book1Dictionary];

    ...

    return [booksInformation copy];
    }

    @end

    //FYPBooksObject.h

    #import <Foundation/Foundation.h>

    @interface FYPBooksObject : NSObject

    @property (strong, nonatomic) NSString *nameB;
    @property (strong, nonatomic) NSString *numberOfPagesB;
    @property (strong, nonatomic) NSString *urlBook;

    -(id)initWithData:(NSDictionary *)data;

    @end

    //FYPBooksObject.m
        #import "FYPBooksObject.h"
        #import "BooksData.h"

        @implementation FYPBooksObject
        -(id)init {
            self = [self initWithData:nil];
            return self;
        }
        -(id)initWithData:(NSDictionary *)data {
            self = [super init];
            self.nameB = data[BOOK_NAME];
            self.numberOfPagesB = data[BOOK_NUMBER_OF_PAGES];
            self.urlBook = data[BOOK_LINK];
            return self;
        }

@end

Please bear with me and give me a full solution to search and display the results for books names in the same table view controller. And if there is a way to do an online search inside the books I'll appreciated..

Scrolling more than one page in a UIPageViewController creates white flash

So I've created a UIPageViewController that works like I want it to except for one thing. If I swipe my finger very fast across the screen, the page scrolls one position to either side, then bounces and displays 3/4th cm of the next page after that again. Like so:

Page zero || (current)Page one --> Scroll to Page two -->Get a glimpse of page three

However, page three isn't loaded yet, because this function only preloads one ViewController at both sides of the current one, and not two, so in my example, it'll preload page zero and two, but not three, hence creating a white glimpse until I intent to scroll there from page two.

Methods preloading the surrounding pages:

-(UIViewController *)pageViewController:(UIPageViewController *)pageViewController
 viewControllerBeforeViewController:(UIViewController *)viewController

-(UIViewController *)pageViewController:(UIPageViewController *)pageViewController
  viewControllerAfterViewController:(UIViewController *)viewController

How can I fix this??

Thank you!

Automatic class generator Xcode

I want to create some class generator with dependencies of user action. For example,

  1. every time I create a new CoreData Entity class I want to create a category class for it with some content already.
  2. Every time i create a sublass of existing class i want some method to be appear in .m file already (like drawInRect: when you create a new UIView sublass.

Example (.h)

@interface MyFavouriteClassSubclass : MyFavouriteClass

(.m):

@implementation MyFavouriteClassSubclass

-(void)someMethodInMyParentClass {
  [super someMethodInMyParentClass];
}

Can that be done?

I was think about some shell script to achive that, but the problem with it, that I already need to have a file, and it can run as a cronjob. I don't think is a good aproach for that.

SKRoutingService not zooming to route after calculated

Is there any known bug to the SKRoutingService not zooming to route after calculating it?

My case scenario is next: I have a list of venues in one view controller. When the user clicks on any of them, another ViewController will open and on them, new instance of SKMapView will be created using this code:

-(void)initMap
{
_map = [[SKMapView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, _mapView.frame.size.height)];

//UIView* userInteractionBlocker = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, _mapView.frame.size.height)];
//[_mapView addSubview:userInteractionBlocker];

_map.settings.rotationEnabled = YES;
_map.settings.displayMode = SKMapDisplayMode2D;

_map.mapScaleView.hidden = YES;
//[map centerOnCurrentPosition];
//[map animateToZoomLevel:25.0];

[SKRoutingService sharedInstance].mapView = _map;
[SKRoutingService sharedInstance].routingDelegate = self;

SKRouteSettings* route = [[SKRouteSettings alloc]init];

route.startCoordinate=CLLocationCoordinate2DMake([Constants shared].selectedExit.lat, [Constants shared].selectedExit.lon);
route.destinationCoordinate=CLLocationCoordinate2DMake([Constants shared].selectedVenue.lat, [Constants shared].selectedVenue.lon);

UIImage *venuePin;
switch (_venue.primary_category) {
    case 626:
        venuePin = [UIImage imageNamed:@"pinGasBlack"];
        break;
    case 623:
        venuePin = [UIImage imageNamed:@"pinHotelBlack"];
        break;
    case 593:
        venuePin = [UIImage imageNamed:@"pinFoodYellow"];
        break;
}
SKAnnotation* exit = [self createPinWithImage:[UIImage imageNamed:@"pinExitYellow"] atCoordinates:CLLocationCoordinate2DMake([Constants shared].selectedExit.lat, [Constants shared].selectedExit.lon) withIdentifier:@"pinExit" identifier:0];
SKAnnotation* venue = [self createPinWithImage:venuePin atCoordinates:CLLocationCoordinate2DMake([Constants shared].selectedVenue.lat, [Constants shared].selectedVenue.lon) withIdentifier:@"pinVenue" identifier:1];

[_map addAnnotation:exit withAnimationSettings:nil];
[_map addAnnotation:venue withAnimationSettings:nil];

[_mapView addSubview:_map];

[[SKRoutingService sharedInstance] calculateRoute:route];
}

- (void)routingService:(SKRoutingService *)routingService didFinishRouteCalculationWithInfo:(SKRouteInformation*)routeInformation{
[[SKRoutingService sharedInstance] zoomToRouteWithInsets:UIEdgeInsetsZero];

}

Thing is, first time I open up a venue screen, route is calculated and zoomed to perfectly.

But once I go back, select another venue and get to the ViewController where another new map should be initialised and zoomed to the route location, it doesn't happen. What happens is: - Map is initialised - Route is calculated - Map Annotations are placed perfectly

But it is zoomed out to showing a planet earth...so completely zoomed out, even though I set

[[SKRoutingService sharedInstance] zoomToRouteWithInsets:UIEdgeInsetsZero];

And I checked, the code is reachable after route calculation, but it simply doesn't zoom?

Any solution to this?

Convert an iOS 8 compatible app to iOS 9

When iOS 8 came out, I had to change my iOS 7 app to be compatible with iOS 8 on code side (using objective C) and especially on UI side, like changes to search view controller and enhancements for iPhone 6 Plus.

So as title indicates; I want to convert the iOS 8 compatible app to iOS 9, what is the best approach to do so? What are the changes in iOS 9 that are not obviously shown or tricks faced in UI mainly?

P.S: I am using Xcode 7 beta 4 right now, and am seeing errors that were passed by Xcode 6. P.P.S: Please Take in consideration that this is a universal app, for iPhone5s and later and iPad 4 and later.

JS getTimezoneOffset() in iOS

In javascript we can get timezone offset with

var current_date = new Date();
current_date.getTimezoneOffset();

Result => -330

I want to get that in iOS (Objective-C)

can someone help please ?

Location is shown 0.0 in iPad and iPod

Hello What is the best way to get the location on the iPad, iPod as well in iPhone.

I have integrated the following but I'm still not able to get the correct current location. On iPod I only get the location for the first time:

+ (GPS*)get 
{
    if (!g_) 
    {
        NSLog(@"Creating instance of GPS!");
        g_ = [GPS new];
    }
    return g_;
}

@synthesize manager;

- (id)init
{
    if (!(self = [super init]))
        return nil;

    //Setup the manager
    manager = [[CLLocationManager alloc] init];
    if (!manager) 
    {
        return nil;
    }
    manager.distanceFilter = kCLDistanceFilterNone;
    manager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters;
    manager.desiredAccuracy = kCLLocationAccuracyBest;
    manager.delegate = self;

    if ([manager respondsToSelector:@selector(pausesLocationUpdatesAutomatically)]) 
    {
        manager.pausesLocationUpdatesAutomatically = NO;
    }
    if ([manager respondsToSelector:@selector(requestAlwaysAuthorization)])
    {
        [manager requestAlwaysAuthorization];
    }

    [manager startUpdatingLocation];

    return self;
}

- (void)start
{
    NSLog(@"Start Tracking");

    [manager startUpdatingLocation];
 }

-(void)stop
{
    [manager stopUpdatingLocation];
}

#pragma mark CLLocationManagerDelegate

- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{
    CLLocation *currentLocation = [locations lastObject];
    NSLog(@"%f : %f", currentLocation.coordinate.latitude, currentLocation.coordinate.longitude);
    //[self writeToFile];
}

- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
{
    NSLog(@"locationManager - didFailWithError: %@", [error localizedDescription]);
    NSLog(@"domain:%@", [error domain]);
    //NSLog(@"code:%i", [error code]);
    //[self writeToFile];
}

Performance of UITableView reloadData, reloadSections:withRowAnimation: and reloadRowsAtIndexPaths:withRowAnimation:

I build a test purpose app to test the performance of these three methods on reloading the table view.

enter image description here

//
//  ViewController.m
//  TableViewSample
//
//  Created by Antonio081014 on 8/2/15.
//  Copyright (c) 2015 Antonio081014.com. All rights reserved.
//

#import "ViewController.h"

@interface ViewController () <UITableViewDataSource, UITableViewDelegate>
@property (nonatomic, strong) NSArray *listOfCards;
@property (nonatomic, strong) NSIndexPath *selectedIndexPath;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.

    NSMutableArray *list = [NSMutableArray array];
    for (int i=0; i<15; i++) {
        NSString *carName = [NSString stringWithFormat:@"Car%d", arc4random() % 15];
        [list addObject:carName];
    }
    self.listOfCards = list;
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.selectedIndexPath = nil;

    UIBarButtonItem *table = [[UIBarButtonItem alloc] initWithTitle:@"Table" style:UIBarButtonItemStylePlain target:self action:@selector(reloadTable:)];
    UIBarButtonItem *section = [[UIBarButtonItem alloc] initWithTitle:@"Section" style:UIBarButtonItemStylePlain target:self action:@selector(reloadSection:)];
    UIBarButtonItem *indexPath = [[UIBarButtonItem alloc] initWithTitle:@"IndexPath" style:UIBarButtonItemStylePlain target:self action:@selector(reloadRow:)];

    self.navigationItem.rightBarButtonItems = @[table, section, indexPath];
//    self.navigationController.navigationItem.rightBarButtonItems = @[table, section, indexPath];
}

- (void)reloadTable:(UIBarButtonItem *)barItem
{
    [self.tableView reloadData];
}

- (void)reloadRow:(UIBarButtonItem *)barItem
{
    [self reloadRowAtIndexPath:self.selectedIndexPath forBarButtonItem:barItem];
}

- (void)reloadSection:(UIBarButtonItem *)barItem
{
    [self reloadSectionAt:0 forBarButtonItem:barItem];
}

- (void)reloadRowAtIndexPath:(NSIndexPath *)indexPath forBarButtonItem:(UIBarButtonItem *)barItem
{
    if (indexPath) {
        [self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
    }
}

- (void)reloadSectionAt:(NSUInteger)section forBarButtonItem:(UIBarButtonItem *)barItem
{
    [self.tableView reloadSections:[[NSIndexSet alloc] initWithIndex:section] withRowAnimation:UITableViewRowAnimationAutomatic];
}


- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    NSLog(@"Asking Number of Sections in TableView");
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    NSLog(@"Asking Number of Rows in Section");
    return self.listOfCards.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];

    NSString *carName = self.listOfCards[indexPath.row];
    cell.textLabel.text = carName;

    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    self.selectedIndexPath = indexPath;
    NSLog(@"Did Select Cell %@", indexPath);
}

- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath
{
    self.selectedIndexPath = nil;
    NSLog(@"Did Deselect Cell %@", indexPath);
}

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSLog(@"Will Display Cell %@", indexPath);
}

- (void)tableView:(UITableView *)tableView didEndDisplayingCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSLog(@"Did End Display Cell %@", indexPath);
}

- (void)tableView:(UITableView *)tableView didHighlightRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSLog(@"Did Highlight Cell %@", indexPath);
}

@end

Log when three methods called.

ReloadData
2015-08-03 11:00:51.556 TableViewSample[324:90811] Did End Display Cell  {length = 2, path = 0 - 11}
2015-08-03 11:00:51.558 TableViewSample[324:90811] Did End Display Cell  {length = 2, path = 0 - 10}
2015-08-03 11:00:51.559 TableViewSample[324:90811] Did End Display Cell  {length = 2, path = 0 - 9}
2015-08-03 11:00:51.560 TableViewSample[324:90811] Did End Display Cell  {length = 2, path = 0 - 8}
2015-08-03 11:00:51.560 TableViewSample[324:90811] Did End Display Cell  {length = 2, path = 0 - 7}
2015-08-03 11:00:51.560 TableViewSample[324:90811] Did End Display Cell  {length = 2, path = 0 - 6}
2015-08-03 11:00:51.561 TableViewSample[324:90811] Did End Display Cell  {length = 2, path = 0 - 5}
2015-08-03 11:00:51.561 TableViewSample[324:90811] Did End Display Cell  {length = 2, path = 0 - 4}
2015-08-03 11:00:51.562 TableViewSample[324:90811] Did End Display Cell  {length = 2, path = 0 - 3}
2015-08-03 11:00:51.563 TableViewSample[324:90811] Did End Display Cell  {length = 2, path = 0 - 2}
2015-08-03 11:00:51.563 TableViewSample[324:90811] Did End Display Cell  {length = 2, path = 0 - 1}
2015-08-03 11:00:51.564 TableViewSample[324:90811] Did End Display Cell  {length = 2, path = 0 - 0}
2015-08-03 11:00:51.564 TableViewSample[324:90811] Asking Number of Sections in TableView
2015-08-03 11:00:51.565 TableViewSample[324:90811] Asking Number of Rows in Section
2015-08-03 11:00:51.566 TableViewSample[324:90811] Will Display Cell  {length = 2, path = 0 - 0}
2015-08-03 11:00:51.567 TableViewSample[324:90811] Will Display Cell  {length = 2, path = 0 - 1}
2015-08-03 11:00:51.567 TableViewSample[324:90811] Will Display Cell  {length = 2, path = 0 - 2}
2015-08-03 11:00:51.568 TableViewSample[324:90811] Will Display Cell  {length = 2, path = 0 - 3}
2015-08-03 11:00:51.569 TableViewSample[324:90811] Will Display Cell  {length = 2, path = 0 - 4}
2015-08-03 11:00:51.569 TableViewSample[324:90811] Will Display Cell  {length = 2, path = 0 - 5}
2015-08-03 11:00:51.570 TableViewSample[324:90811] Will Display Cell  {length = 2, path = 0 - 6}
2015-08-03 11:00:51.571 TableViewSample[324:90811] Will Display Cell  {length = 2, path = 0 - 7}
2015-08-03 11:00:51.572 TableViewSample[324:90811] Will Display Cell  {length = 2, path = 0 - 8}
2015-08-03 11:00:51.573 TableViewSample[324:90811] Will Display Cell  {length = 2, path = 0 - 9}
2015-08-03 11:00:51.573 TableViewSample[324:90811] Will Display Cell  {length = 2, path = 0 - 10}
2015-08-03 11:00:51.574 TableViewSample[324:90811] Will Display Cell  {length = 2, path = 0 - 11}


ReloadSection
2015-08-03 11:02:21.641 TableViewSample[324:90811] Asking Number of Sections in TableView
2015-08-03 11:02:21.642 TableViewSample[324:90811] Asking Number of Sections in TableView
2015-08-03 11:02:21.643 TableViewSample[324:90811] Asking Number of Rows in Section
2015-08-03 11:02:21.647 TableViewSample[324:90811] Will Display Cell  {length = 2, path = 0 - 0}
2015-08-03 11:02:21.649 TableViewSample[324:90811] Will Display Cell  {length = 2, path = 0 - 1}
2015-08-03 11:02:21.651 TableViewSample[324:90811] Will Display Cell  {length = 2, path = 0 - 2}
2015-08-03 11:02:21.653 TableViewSample[324:90811] Will Display Cell  {length = 2, path = 0 - 3}
2015-08-03 11:02:21.655 TableViewSample[324:90811] Will Display Cell  {length = 2, path = 0 - 4}
2015-08-03 11:02:21.657 TableViewSample[324:90811] Will Display Cell  {length = 2, path = 0 - 5}
2015-08-03 11:02:21.659 TableViewSample[324:90811] Will Display Cell  {length = 2, path = 0 - 6}
2015-08-03 11:02:21.662 TableViewSample[324:90811] Will Display Cell  {length = 2, path = 0 - 7}
2015-08-03 11:02:21.664 TableViewSample[324:90811] Will Display Cell  {length = 2, path = 0 - 8}
2015-08-03 11:02:21.666 TableViewSample[324:90811] Will Display Cell  {length = 2, path = 0 - 9}
2015-08-03 11:02:21.669 TableViewSample[324:90811] Will Display Cell  {length = 2, path = 0 - 10}
2015-08-03 11:02:21.671 TableViewSample[324:90811] Will Display Cell  {length = 2, path = 0 - 11}
2015-08-03 11:02:21.990 TableViewSample[324:90811] Did End Display Cell  {length = 2, path = 0 - 0}
2015-08-03 11:02:21.991 TableViewSample[324:90811] Did End Display Cell  {length = 2, path = 0 - 1}
2015-08-03 11:02:21.992 TableViewSample[324:90811] Did End Display Cell  {length = 2, path = 0 - 2}
2015-08-03 11:02:21.992 TableViewSample[324:90811] Did End Display Cell  {length = 2, path = 0 - 3}
2015-08-03 11:02:21.993 TableViewSample[324:90811] Did End Display Cell  {length = 2, path = 0 - 4}
2015-08-03 11:02:21.994 TableViewSample[324:90811] Did End Display Cell  {length = 2, path = 0 - 5}
2015-08-03 11:02:21.994 TableViewSample[324:90811] Did End Display Cell  {length = 2, path = 0 - 6}
2015-08-03 11:02:21.995 TableViewSample[324:90811] Did End Display Cell  {length = 2, path = 0 - 7}
2015-08-03 11:02:21.995 TableViewSample[324:90811] Did End Display Cell  {length = 2, path = 0 - 8}
2015-08-03 11:02:21.996 TableViewSample[324:90811] Did End Display Cell  {length = 2, path = 0 - 9}
2015-08-03 11:02:21.997 TableViewSample[324:90811] Did End Display Cell  {length = 2, path = 0 - 10}
2015-08-03 11:02:21.997 TableViewSample[324:90811] Did End Display Cell  {length = 2, path = 0 - 11}

ReloadRow
2015-08-03 11:03:00.012 TableViewSample[324:90811] Did Highlight Cell  {length = 2, path = 0 - 3}
2015-08-03 11:03:00.015 TableViewSample[324:90811] Did Select Cell  {length = 2, path = 0 - 3}
2015-08-03 11:03:00.907 TableViewSample[324:90811] Asking Number of Sections in TableView
2015-08-03 11:03:00.908 TableViewSample[324:90811] Asking Number of Sections in TableView
2015-08-03 11:03:00.909 TableViewSample[324:90811] Asking Number of Rows in Section
2015-08-03 11:03:00.910 TableViewSample[324:90811] Will Display Cell  {length = 2, path = 0 - 3}
2015-08-03 11:03:01.217 TableViewSample[324:90811] Did End Display Cell  {length = 2, path = 0 - 3}

So, from the log: [UITableView reloadData] consumes 16ms. [UITableView reloadSections:withRowAnimation:] consumes 323ms. [UITableView reloadRowsAtIndexPaths:withRowAnimation:] consumes 302ms.

Question:

  • Why [UITableView reloadData] is more efficient than reloadingSections even there is only one section?
  • Why reloadingRowsAtIndexPaths takes that much of time, what actually takes the time?
  • What kind of tools could help me verify or debug similar problems? and helper link reference if any?
  • Thanks.

How do you ignore a collision (e.g. the ground in a scene) while still responding to others in sprite kit?

From what I understand, you must set up category bit masks such (static const uint32_t chickenCategory = 0x1 << 0;) but when i set up my program, it still registers contact with ground in the didBeginContact method. From what i've found online, you can do this: cow.physicsBody.contactTestBitMask= obstacleCategory | ~groundCategory;

this is supposed to ignore the contact collision detection with the ground category but its not working. Apparently this works with the old Xcode but not the new one (version 6.4).