Post not yet marked as solved
error desc: Reached end of file while looking for: Mach-O slice.
Xcode version :13.2.1
please, how to do it ?
Post not yet marked as solved
Hey everyone I've been tasked to do some back end work for my app and just looking for a little guidance or advice.
I have an app that will need to be connected to a local network only DB. No cloud services can be used. I found some useful information from Code with Chris, https://*******.com/2kfmv8vw ,but seems from the comments it might be a little outdated. I know for sure I'll be using PHP to connect the two but just wanted to see if anyone had any suggestions before I started this journey. Any help is welcome
Post not yet marked as solved
I have an Objective-C macOS app which provides a service that provides unique services on selected text.
This app has been for sale in the Mac App Store for several years.
The app registers as service provider during 'appDidFinishLaunching' with: [[NSApplication sharedApplication] setServicesProvider:self];
When my service is invoked it uses the standard service method:
(void)serviceName:(NSPasteboard *)pboard userData:(NSString *)userData error:(NSString **)error
In the body of this standard service method the contents of the NSPasteboard (pboard) are examined and consumed by my app.
- (void) kudosService:(NSPasteboard *)pboard userData:(NSString *)userData error:(NSString **)error; {
if ([pboard pasteboardItems].count==0) { return; }
NSPasteboardItem *pI = [pboard pasteboardItems][0];
NSLog(@"pI:%@",pI.types );
for (NSString *uti in pI.types) {
NSLog(@"uti:%@ string:%@",uti, [pI stringForType:uti] );
}
...
}
Something has changed with Preview app; at this point I'm inclined to think the change occurred with version 11.
Console output for Preview
pI:(
"public.utf8-plain-text",
"public.rtf",
"public.utf16-external-plain-text"
)
uti:public.utf8-plain-text string:(null)
uti:public.rtf string:(null)
uti:public.utf16-external-plain-text string:(null)
This is the output regardless of whether or not the user has a mere text selection OR has formally 'Cop(ied)' [Cmd-C] the text in the Preview window!
Please NOTE if I open the exact same .pdf document in Safari and invoke the service from Safari I see the expected Console output:
pI:(
"public.utf8-plain-text"
)
uti:public.utf8-plain-text string:The Best Gluten-Free Chocolate Cake
When did this change in Preview behavior occur?
Can anyone point me to some documentation, which I have obviously overlooked, that would shed some light on this matter!
Post not yet marked as solved
Hello,
I am facing a problem in including a C++ header file like vector, set etc. in a objective-c++ header.
Lets suppose, I am having 2 files:
abc.h
abc.mm
Now, when I try to include the C++ header in abc.mm file, no build error is coming.
But when I try to include the C++ header in abc.h file, it is throwing build error.
Build error is: Header not found.
How to resolve this error? Any suggestion will be helpful.
Thanks
Asheesh
Post not yet marked as solved
I have an older MacOS app where in IB (no storyboards) I created a main window/view and a progress window/view in one xib in response to a menu item. In a new MacOS app (using much of the code from the older menu item code), in IB storyboard I have a window controller/window/view/subviews in the storyboard, but I cannot seem to find a way to also include in the storyboard a progress panel (to hook up to an outlet in the view controller).
I can create the same window/panel/progress bar that I had in the older app in a separate xib. So I suppose (in objective c) I can just load the xib???
So, is there a better way to implement a separate progress window(s) in a storyboard and hook them up to outlets? I think I'm missing something
And what happened to NSPanels?
Post not yet marked as solved
#define KdownloadsPath NSSearchPathForDirectoriesInDomains(NSDownloadsDirectory, NSUserDomainMask, YES).firstObject
_downloadedPath = [KdownloadsPath stringByAppendingPathComponent:fileName];
_downloadingPath = [_downloadedPath stringByAppendingString:@".download"];
NSDictionary* info = [NSDictionary dictionaryWithObjectsAndKeys:
@"NSProgressFileOperationKindDownloading", @"NSProgressFileOperationKindKey",
[NSURL fileURLWithPath:_downloadingPath], @"NSProgressFileURLKey",
nil];
self.progress = [[NSProgress alloc] initWithParent:nil userInfo:info];
[self.progress setKind:@"NSProgressKindFile"];
[self.progress setPausable:NO];
[self.progress setCancellable:YES];
[self.progress setTotalUnitCount:_totalBytes];
[self.progress publish];
(updating the progress indicator happens elsewhere)
I'm creating an NSProgress object to show a progress indicator underneat a file in my Downloads directory. The entitlements includes com.apple.security.files.downloads.read-write.
The indicator does not show when NSProgressFileURLKey points to the sandboxed file path, e.g. /Users/mdbraber/Library/Containers/com.mdbraber.TestApp/Data/Downloads/Test.pptx.download. It does work when NSProgressFileURLKey points to the direct download location which the sandbox links to e.g. /Users/mdbraber/Downloads/Test.pptx.download
Is this a bug or should I use something else for NSProgressFileURLKey to make this work?
Post not yet marked as solved
The following is my code to show text in textview. But the error, EXC_BAD_INSTRUCTION, happens while executing it.
How does this error happen and how could I fix it?
dispatch_sync(dispatch_get_main_queue(), ^{
[[[Memo1 textStorage] mutableString]appendString:[NSString stringWithFormat:@"%@", str]];
[Memo1 scrollRangeToVisible:NSMakeRange(Memo1.string.length, 0)];//auto scroll down
});
Post not yet marked as solved
What is the word in programming that means that checks a condition for true or false, and if the condition is false, code is run to make that condition true, so that if the condition is checked again, it would be true?
I believe I have seen something in Swift or Foundations that does this as applied to different things.
Hi,
I have a log to file function that as part of the logline inserts the current datetime as below:
class func logToFile(message: String, logInfo: LogInfo = appLogInfo, type: OSLogType = .default) {
let formatter = DateFormatter()
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS"
formatter.timeZone = TimeZone(secondsFromGMT: TimeZone.current.secondsFromGMT())
formatter.locale = Locale(identifier: "en_US_POSIX")
let localDate = formatter.string(from: Date())
let logMessage = "\(localDate) [\(logInfo.category)] \(message)\n"
let documentDirPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0]
let filePath = "\(documentDirPath)/\(logFileName)"
if let fileHandle = FileHandle.init(forWritingAtPath: filePath), let data = logMessage.data(using: .utf8) {
fileHandle.seekToEndOfFile()
fileHandle.write(data)
}
}
and it is always called from a serial queue:
Log.serialQueue.async {
logToFile(message: message, logInfo: logInfo, type: type)
}
Lately however, I am getting some crashes and I managed to catch one in the debugger. It happens when deallocating the local DateFormatter when exiting the logToFile function.
Xcode stops at the end of the function:
And the thread indicates that it is inside NSDateFormatter dealloc
and clicking on the ici::Dataformat destructor, the assembly code shows this:
And in the inspector, we can see that localDate is half-baked, it only contains the year and day:
I have found some posts on DateFormatter not being thread safe but that was way in the past. In my case I only want to convert a Date() to String.
Something is not working as expected and suggestions on how to improve it would be very welcome.
Thanks in advance
Post not yet marked as solved
Hi,
I have no idea what happened, I got no warnings, no error.
When I used the Sandbox I got a GL_INVALID_VALUE error.
Please have I look at the attachments for illustration.
Post not yet marked as solved
Xcode show this error. and cannot jump to project navigator..I cannot find the real issue... BTW:I use objective-C.
error build: 5457 duplicate symbols for architecture arm64
Post not yet marked as solved
I have a button that starts tests. The items, test no, min and max are added to the table_array and refresh table to show them.
Following code runs without error.
index++;
//if([[Elect objectAtIndex:index]isEqualToString:@"1"])
item++;
temp = [self GetDCVoltage_34970:1];
if(temp >= [[Min objectAtIndex:index]floatValue] && temp <= [[Max objectAtIndex:index]floatValue])
[table_status addObject:@"Pass"];
else
{
PF=false; [table_status addObject:@"Fail"];
err=101+item; [errcode setIntValue:err];
}
[table_no addObject:[NSString stringWithFormat:@"%d",item]];
[self Show_Datagrid:index];
[table_value addObject:[NSString stringWithFormat:@"%.3f",temp]];
[Test_value replaceObjectAtIndex:index withObject:[NSString stringWithFormat:@"%.3f",temp]];
[self refreshTable];
//if (continue_test.state==0 && PF==false)
//return;
return;
After I removed some lines, I only remain the lines that add objects to table_array. Then it shows up error: Thread1: EXE_BAD_INSTRUTION after I pressed button.
[table_no addObject:[NSString stringWithFormat:@"%d",item]];
[self Show_Datagrid:index];
[table_value addObject:[NSString stringWithFormat:@"%.3f",temp]];
[Test_value replaceObjectAtIndex:index withObject:[NSString stringWithFormat:@"%.3f",temp]];
[self refreshTable];
Post not yet marked as solved
Am new to objective c I need to set a characteristic data which I get from a Bluetooth using CB read to Byte array then return a byte buffer.
the same is written in java how can I do the same in objective c
dataArray = characteristic.getValue();
tsLong = System.currentTimeMillis() - tsStart;
float timeSeconds = (float) ((float) tsLong / 1000.0);
String timerstring = String.format("%.2f", timeSeconds);
message = convertByteToChannelData(ByteBuffer.wrap(dataArray), timerstring, 0);
this is the convertByteToChannelData method
public String convertByteToChannelData(ByteBuffer wrap,String timerString, int stimulus){
wrap.order(ByteOrder.LITTLE_ENDIAN);
// Set 1 Channels
// Channels 1, 5, 6, 11, 16, 17
ch1R = (float) ((wrap.getShort(0) / 4095.) * 3.3);
ch1Rs = (float) ((wrap.getShort(4) / 4095.) * 3.3);
ch5R = (float) ((wrap.getShort(12) / 4095.) * 3.3);
ch5Rs = (float) ((wrap.getShort(4) / 4095.) * 3.3);
ch6R = (float) ((wrap.getShort(6) / 4095.) * 3.3);
}
Post not yet marked as solved
Hi everybody.
I have an application written in Objective-C. Until recently, I continued to maintain it and write new features in Objective-C. It was decided to switch to Swift and implement all new features on Swift. As a result, I made a bridge between Objective-C and Swift. Added new classes in swift and imported them via bridge header. One of the tasks required adding functionality to an existing Objective-C class, but I decided to implement this by extending the Objective-C class in a swift file.
Example Objective-C class
Settings.h
#import <Foundation/Foundation.h>
@interface Settings : NSObject
- (instancetype)initWithDictionary:(NSDictionary *)dictionary;
- (BOOL)boolForKey:(NSString *)key;
@end
Settings.m
#import "Settings.h"
@implementation Settings {
NSDictionary *_dictionary;
}
- (instancetype)initWithDictionary:(NSDictionary *)dictionary {
self = [super init];
if (self) {
_dictionary = dictionary;
}
return self;
}
- (BOOL)boolForKey:(NSString *)key {
return [[_dictionary objectForKey:key] boolValue];
}
@end
Swift extension
Settings+extension.swift
import Foundation
extension Settings {
@objc public func isFirstProperty() -> Bool {
return self.bool(forKey: "isFirstProperty")
}
@objc public func isSecondProperty() -> Bool {
return self.bool(forKey: "isSecondProperty")
}
}
Call example inside UICollectionViewController sub class
@implementation CollectionViewController {
Settings* _settings;
}
-(void)viewDidLoad {
[super viewDidLoad];
_settings = [[Settings alloc] initWithDictionary:someDictionary];
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"reuseIdentifier" forIndexPath:indexPath];
if ([_settings isFirstProperty]) {
//Do something with cell according to firstProperty
} else if ([_settings isSecondProperty]) {
//Do something with cell according to secondProperty
}
return cell;
}
@end
I tested the app, everything worked great.
I uploaded the app to the App Store. Almost from the beginning of the use of the new application by users, I began to receive crash reports.
Crash report
Stack Trace
I could not understand what was the matter. But after I removed the Swift extensions and implemented them directly in the Objective-C class, the crashes stopped.
After removing Settings+extension.swift and implementing inside Settings.m/h
Example Objective-C class
Settings.h
#import <Foundation/Foundation.h>
@interface Settings : NSObject
- (instancetype)initWithDictionary:(NSDictionary *)dictionary;
- (BOOL)boolForKey:(NSString *)key;
- (BOOL)isFirstProperty;
- (BOOL)isSecondProperty;
@end
Settings.m
#import "Settings.h"
@implementation Settings {
NSDictionary *_dictionary;
}
- (instancetype)initWithDictionary:(NSDictionary *)dictionary {
self = [super init];
if (self) {
_dictionary = dictionary;
}
return self;
}
- (BOOL)isFirstProperty {
return [[_dictionary objectForKey:key] boolValue];
}
- (BOOL)isSecondProperty {
return [[_dictionary objectForKey:key] boolValue];
}
@end
1. Can somebody explain, why I had crashes?
2. Is it ok to extend Objective-C classes like that?
3. What kind of issues I can expect during migration to swift ?from Objective-C? (Any literature that explore this topic?)
Thanks in advance!
Post not yet marked as solved
Hi,
I was working on a feature based on dns packet parsing in the VPN solution of my app on iOS.
I was using the dns_parse_packet api from dnsutils.h class, which was able to parse dns requests and reply packets from raw bytes quite efficiently.
I had tested this flow on iOS 15.2 but after updating to iOS 15.5 this api does not seem to work anymore.
Has this API been deprecated or is this a bug in iOS 15.5?
Post not yet marked as solved
I hope the table column show the values after I pressed the button. The following is the IBAction Button.
- (IBAction)buttonTapped:(id)sender
{
//Filling the arrays
Test_name = [NSArray arrayWithObjects:@"test_item_a",@"b",@"c",@"Current",nil];
Min = [NSArray arrayWithObjects:@"0.5",@"0.7",@"0.8",@"100",nil];
Max = [NSArray arrayWithObjects:@"5",@"5",@"9",@"140",nil];
uint16 index = 0;
NSInteger i = 0;
//Show_Datagrid this function move the above values to another 3 arrays table_item,
//table_min, table_max. And the following code is just to verify the value.
[self Show_Datagrid:index];
[self showMeg:@"Button Tapped!2\n"];
[self showMeg:[table_item objectAtIndex:0]];
[self showMeg:@"\n"];
[self showMeg:[table_min objectAtIndex:0]];
[self showMeg:@"\n"];
[self showMeg:Column_test_item.identifier];
//call this function to show the values in tableview.
[self tableView:_tableview objectValueForTableColumn:Column_test_item row:i];
}
following is the function (Column_test_item.identifier is verified correct.):
-(id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
{
if ([aTableColumn.identifier isEqualToString:@"no"])
return [table_no objectAtIndex:rowIndex];
if ([aTableColumn.identifier isEqualToString:@"item"])
return [table_item objectAtIndex:rowIndex];
if ([aTableColumn.identifier isEqualToString:@"min"])
return [table_min objectAtIndex:rowIndex];
if ([aTableColumn.identifier isEqualToString:@"max"])
return [table_max objectAtIndex:rowIndex];
if ([aTableColumn.identifier isEqualToString:@"value"])
return [table_value objectAtIndex:rowIndex];
if ([aTableColumn.identifier isEqualToString:@"status"])
return [table_status objectAtIndex:rowIndex];
return [table_no objectAtIndex:rowIndex];
}
I thnik I called that function in wrong way. Shouldn't I input NSTableColumn parameter Column_test_item directly? Column_test_item is an IBOutlet I connected to the specfic test item column.
And how does this function know which column it want to fill up the value, based on the second parameter I input?
Post not yet marked as solved
Is objective -c deprecated ? Apple support is available ?
Post not yet marked as solved
Hi Team,
I facing a problem with building my app, After update into the latest version Xcode 13.4, I had a few problems which were successfully solved. However one of them stopped me for a few hours. The problem is with Swift Compiler or Bridging Headers is unsupported, I really don't know what causes problems.
On several forums I often read that is important to set:
Build Settings > Build Options > Build Libraries for Distribution = YES
If I set it ‘YES’ I getting - error: using bridging headers with module interfaces is unsupported
If I set it ‘NO’ I getting - error: module compiled with Swift 5.0.1 cannot be imported by the Swift 5.2.2 compiler, for some framework or classes.
Can you please guide me, what should I do to resolve this issue ?
Post not yet marked as solved
I am trying to develop a plug in for motion in Objective-c using the FxPlug template and so far I have been having issues with getting "NSOpenPanel" to be called from a push button in order to get a file dialog window, similar to the "File" generator present in Motion.
[paramAPI addPushButtonWithName: @"MIDI file"
parameterID: 1
selector: @selector(MIDI_func)
parameterFlags: kFxParameterFlag_DEFAULT]
I have tried to call NSOpenPanel through "dispatch_async" so that it would run on the main thread and thus not crash but when I press the button it appears not to work
- (void)MIDI_func {
NSLog(@"Button pressed");
dispatch_async(dispatch_get_main_queue(), ^{
NSOpenPanel* openDlg = [NSOpenPanel openPanel];
[openDlg setCanChooseFiles:YES];
[openDlg setAllowsMultipleSelection:NO];
[openDlg setCanChooseDirectories:NO];
if ([openDlg runModal] == NSModalResponseOK) {
NSArray* urls = [openDlg URLs];
for(NSInteger i = 0; i < [urls count]; i++ ) {
NSString* url = [urls objectAtIndex:i];
NSLog(@"Url: %@", url);
}
}
});
}
How can I achieve this or is there a function in the FxPlug SDK that will let me open a file dialog from the host application?
Post not yet marked as solved
I am attempting to dynamically clone a class object in Swift using reflection and the setValue function. This class contains an enum property that is backed with an Int, which is causing this dynamic reflection to crash:
@objc enum Status : Int {
case green
case yellow
case red
}
@objc class State : NSObject {
@objc var status : Status
init(_ status: Status) {
self.status = status
}
}
func testReflectiveClone() {
let state1 = State(.green)
let state2 = State(.yellow)
let state1Mirror = Mirror(reflecting: state1)
for property in state1Mirror.children.enumerated() {
let label = property.element.label
state2.setValue(property.element.value, forKey: label!) //crashes here
}
}
This test function is throwing the following error in XCode:
-[__SwiftValue longLongValue]: unrecognized selector sent to instance 0x600001e5a340 (NSInvalidArgumentException)
Is it even possible to dynamically set enum values? What modification would I need to make to get this to work?