Getting "Incompatible pointer types sending 'UIImage *' to parameter of type 'CIImage * _Nonnull' with JSQMessagesViewController - jsqmessagesviewcontroller

JSQMessagesViewController
Using Xcode 7.0 Beta 5, I'm getting a warning of an "Incompatible pointer types sending 'UIImage *' to parameter of type 'CIImage * _Nonnull' in the copyWithZone method of JSQPhotoMediaItem.
Here's the method:
- (instancetype)copyWithZone:(NSZone *)zone
{
JSQPhotoMediaItem *copy = [[[self class] allocWithZone:zone] initWithImage:self.image];
copy.appliesMediaViewMaskAsOutgoing = self.appliesMediaViewMaskAsOutgoing;
return copy;
}
The warning is for the first line initializing the JSQPhotoMediaItem, and the initWithImage shows that it expects a (UIImage *)
- (instancetype)initWithImage:(UIImage *)image
{
self = [super init];
if (self) {
_image = [image copy];
_cachedImageView = nil;
}
return self;
}
It also reports that: "Passing argument to paramteter 'im' here" referencing CISampler.h, which indeed has an initWithImage(CIImage *) im[![enter image description here][1]][1]
Thanks.

change
JSQPhotoMediaItem *copy = [[[self class] allocWithZone:zone] initWithImage:self.image];
into
JSQPhotoMediaItem *copy = [[JSQPhotoMediaItem allocWithZone:zone] initWithImage:self.image];
will get rid of this warning.

Related

No drop with NSDraggingSession

In the "mouseDown" code below Enclosure is a NSView subclass.
xcode report 2 warnings:
1)
[pb_item setDataProvider:self forTypes:[NSArray arrayWithObjects:NSPasteboardTypeTIFF, NSPasteboardTypePDF, #"LN_PboardType", nil]];
Sending 'Enclosure *' to parameter of incompatible type 'id<NSPasteboardItemDataProvider> _Nonnull'
NSDraggingSession *draggingSession = [self beginDraggingSessionWithItems:[NSArray arrayWithObject:drag_item] event:drag_event source:self];
Sending 'Enclosure *' to parameter of incompatible type 'id _Nonnull'
The application fail at:
drag_item = [[NSDraggingItem alloc] initWithPasteboardWriter:pb_item];
Pasteboard item data provider <Enclosure: 0x7f849ec74e70> must conform to NSPasteboardItemDataProviderProtocol
[General] There are 0 items on the pasteboard, but 1 drag images. There must be 1 draggingItem per pasteboardItem.
However if in the line of code above "pb_item" is replaced by "drag_image" drag work fine (but without drop).
The z_drag image follow the mouse correctly and "endedAtPoint" is called when the mouse button is released.
Where is the error ?
Any suggestion will be appreciate...
BigSur, xcode 12.4
- (void)mouseDown:(NSEvent *)drag_event /* or mouseDragged:(NSEvent *)drag_event */
{
NSImage *drag_image;
NSPoint drag_position;
NSDraggingItem *drag_item;
NSPasteboardItem *pb_item;
pb_item = [[NSPasteboardItem alloc] init];
[pb_item setDataProvider:self forTypes:[NSArray arrayWithObjects:NSPasteboardTypeTIFF, NSPasteboardTypePDF, #"LN_PboardType", nil]];
drag_image = [NSImage imageNamed:#"z_drag.jpg"];
drag_item = [[NSDraggingItem alloc] initWithPasteboardWriter:pb_item];
drag_position = [self convertPoint:[drag_event locationInWindow] fromView:nil];
drag_position.x -= [drag_image size].width/2;
drag_position.y -= [drag_image size].height/2;
[drag_item setDraggingFrame:NSMakeRect(drag_position.x, drag_position.y, drag_image.size.width, drag_image.size.height) contents:drag_image];
NSDraggingSession *draggingSession = [self beginDraggingSessionWithItems:[NSArray arrayWithObject:drag_item] event:drag_event source:self];
[draggingSession setAnimatesToStartingPositionsOnCancelOrFail:YES];
[draggingSession setDraggingFormation:NSDraggingFormationNone];
}
- (NSDragOperation)draggingSession:(NSDraggingSession *)session sourceOperationMaskForDraggingContext:(NSDraggingContext)context
{
switch (context)
{
case NSDraggingContextWithinApplication:
return NSDragOperationCopy;
case NSDraggingContextOutsideApplication:
return NSDragOperationMove;
}
return NSDragOperationNone;
}
- (void)draggingSession:(NSDraggingSession *)session endedAtPoint:(NSPoint)screenPoint operation:(NSDragOperation)operation
{
NSPoint mouse_point;
mouse_point = [session draggingLocation];
switch (operation)
{
case NSDragOperationDelete:
break;
default:
break;
}
}

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', unrecognized selector sent to instance 0x7fe318e825f0'

- (void)viewDidLoad
{
[super viewDidLoad];
//array with image filenames and country names
_paths = [[NSBundle mainBundle] pathsForResourcesOfType:#"png" inDirectory:self.itemName];
NSLog(#"%#",self.itemName);
_country=_paths;
for(int i=0;i <[_paths count];i++)
{
NSString *append=[_paths objectAtIndex:i];
NSString *temp= [NSArray arrayWithObject:[[ append componentsSeparatedByString:#"/"] lastObject]];
NSString *temp1= [NSArray arrayWithObject:[[ append componentsSeparatedByString:#"-"] lastObject]];
[_paths replaceObjectAtIndex:i withObject:temp];
[_country replaceObjectAtIndex:i withObject:temp1];
}
// Connect data
self.myPickerView.dataSource = self;
self.myPickerView.delegate = self;
self.maxIndex = [_country count];
self.displayedFlagIndex = arc4random() % self.maxIndex;
[self.ImageItem setImage:[UIImage imageNamed: _paths[self.displayedFlagIndex]]];
UITapGestureRecognizer *tapGR = [[UITapGestureRecognizer alloc]
initWithTarget:self action:#selector(tapHandler:)];
tapGR.numberOfTapsRequired = 1; // set appropriate GR attributes
self.ImageItem.userInteractionEnabled = YES;
[self.ImageItem addGestureRecognizer:tapGR]; // add GR to view
self.myTextield.delegate=(id)self;
}
// set image displayed based on item selected
// self.itemImage.image = [images objectAtIndex:self.itemNumber];
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void) tapHandler: (UITapGestureRecognizer *) sender
{
_myTextield.text=#"";
NSLog(#"in tapHandler");
self.displayedFlagIndex = arc4random() % self.maxIndex;
[self.ImageItem setImage:[UIImage imageNamed: _paths[self.displayedFlagIndex]]];
}
I am trying to implement navigation controller with a table view and view controllers. Will post more code if required.
I have checked that the tapRecognizer method calls the tapHandler: method and not any other. But it still throws the exception of unrecognized selector sent to the instance.
-Thanks!
Your issue is that _paths[self.displayedFlagIndex] returns a NSArray (with one object) object whereas you expect a NSString for imageNamed: method of UIImage.
That's why you're getting the error:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayI length]:
unrecognized selector sent to instance 0x7fd563f3a140'
The origin of your issue:
NSString *temp = [NSArray arrayWithObject:[[append componentsSeparatedByString:#"/"] lastObject]];
NSString *temp1 = [NSArray arrayWithObject:[[append componentsSeparatedByString:#"-"] lastObject]];
This should clearly throw a warning saying that's you can mix like that NSString and NSArray
You should do this instead:
NSString *temp = [[append componentsSeparatedByString:#"/"] lastObject];
NSString *temp1 = [[append componentsSeparatedByString:#"-"] lastObject];

CKSMSComposeRemoteViewController timed out waiting for fence barrier from com.apple.mobilesms.compose

Ok, so sendSMS worked fine before on ios7 and below. However, on ios8 the sendSMS function just fails with the error in the title of the question. I am getting a warning here (after trying to resolve by changing NSArray to NSString using other stack overflow questions): Incompatible pointer types assigning to 'NSArray *' from 'NSString *' for controller.recipients = recipients; It is returning a result of MessageComposeResultCancelled.
if (ABMultiValueGetCount(phoneNumbers) > 0) {
phone = (__bridge_transfer NSString*)
ABMultiValueCopyValueAtIndex(phoneNumbers, 0);
[self sendSMS:#"Play me on PokerBuddies.
Download the app at: https://itunes.apple.com/us/app /poker-buddies/id404168013?mt=8"
recipientList:[NSString stringWithFormat:phone, nil]];
} else {
phone = #"[None]";
}
- (void)sendSMS:(NSString *)bodyOfMessage recipientList:(NSString *)recipients{
MFMessageComposeViewController *controller = [[MFMessageComposeViewController alloc] init];
if([MFMessageComposeViewController canSendText]){
controller.body = bodyOfMessage;
controller.recipients = recipients;
controller.messageComposeDelegate = self;
[self presentViewController:controller animated:YES completion:nil];
NSLog(#"Send SMS");
}
}
I have same problem like MessageComposeController timeout issue .
I solved it by doing this.
You have to create instance variable of MFMessageComposeViewController and when you are going to present message controller you have to check if instance object is already created then do it nil and initialize that object again.So this error "CKSMSComposeRemoteViewController timed out waiting for fence barrier from com.apple.mobilesms.compose" will not come and controller open exactly.
if ([MFMessageComposeViewController canSendText]) {
if (messageComposer) {
messageComposer = nil;
messageComposer = [[MFMessageComposeViewController alloc]init];
}
messageComposer.recipients = arrPhoneNumber;
messageComposer.messageComposeDelegate = self;
messageComposer.body = #"Your text";
isMessageComposeAppear = 1;
[self presentViewController:messageComposer animated:YES completion:nil];
}

How to address a "Implicit conversion of an Objective-C pointer to 'const void' is disallowed" error when using [NSValue valueWithPointer:t]?

How do I fix the error "Implicit conversion of an Objective-C pointer to 'const void' is disallowed" when using the following message:
NSValue *key = [NSValue valueWithPointer:t];
Extra thanks goes to the one can offer why this code throws this exception if simple, newbie terms.
Here is the full method if it helps:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
for (UITouch *t in touches) {
// Is this a double tap?
if ([t tapCount] > 1) {
[self clearAll];
return;
}
// Use the touch object (packed in an NSValue) as the key
NSValue *key = [NSValue valueWithPointer:t]; // here is where the error is
// Create a line for the value
CGPoint loc = [t locationInView:self];
Line *newLine = [[Line alloc] init];
[newLine setBegin:loc];
[newLine setEnd:loc];
// Put pair in dictionary
[linesInProcess setObject:newLine forKey:key];
}
I ran into the same problem working on that exercise in the second edition of the Big Nerd Range Guide, which doesn't cover ARC. That's where the issue arises. They've updated their example/solution code here: http://www.bignerdranch.com/solutions/iOSProgramming3ed.zip
Within that, you can see they've changed that line to:
NSValue *key = [NSValue valueWithNonretainedObject:t];
Try to simply add (_bridge void) !

Incompatible pointer type with NSDate

I can't see why this doesn't work. The following code block throws a warning at the addObject line: "Passing argument 1 of 'taskWithText:dueDate:' from incompatible pointer type"
- (id)init{
self = [super init];
if (self) {
taskListArray = [[NSMutableArray alloc] init];
[taskListArray addObject:[AFLTask taskWithText:"#Helloski" dueDate:[NSDate dateWithNaturalLanguageString:#"12/31/12"]]];
}
return self;
}
It's so simple I don't see why it doesn't work. It seems to match my method:
- (id)initWithText:(NSString *)newText dueDate:(NSDate *)newDueDate{
if(self = [super init]){
taskText = [newText retain];
taskDue = [newDueDate retain];
taskCompleted = NO;
}
return self;
}
+ (id)taskWithText:(NSString *)newText dueDate:(NSDate *)newDueDate{
return [[[AFLTask alloc] initWithText:newText dueDate:newDueDate] autorelease];
}
What is going on here? I'm pretty new to Objective-C (but not programming in general) and so I'm still trying to wrap my head around pointers -- but shouldn't this work?
You're going to kick yourself:
"#Helloski"
should be
#"Helloski"

Resources