0
votes

I recently made a .dylib and it doesn't work. I was told some things were wrong and I wan missing stuff. I need you guys to tell me what I'm missing.

#import <CoreFoundation/CoreFoundation.h>
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "libactivator.h"
#include <stdio.h>
#include <dlfcn.h>
#include <unistd.h>

@interface ASListener : NSObject<LAListener, UITextViewDelegate, UIAlertViewDelegate> {

@private

        UIAlertView *av;
        UITextView *scriptField;
}

@end



@implementation ASListener


- (void)dismiss
{
        if (av) {
                [av dismissWithClickedButtonIndex:[av cancelButtonIndex] animated:YES];
                [av release];
                av = nil;
        }
}

- (void)activator:(LAActivator *) receiveEvent:(LAEvent *)event
{

        [self dismiss];

        av = [[UIAlertView alloc] initWithTitle:@"AlertScript" message:@" " delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Exec", nil];

[av show];
[av release];

scriptField = [[UITextView alloc] initWithFrame: CGRectMake(10, 10, 255, 151)];

[av addSubview:scriptField];

if(scriptField) {
        scriptField.delegate = self;
        scriptField.editable = YES;
}
NSString *script = scriptField.text;

[script writeToFile:@"/usr/bin/AlertScript" 
atomically:YES encoding:NSUnicodeStringEncoding error:nil];

        [UITextView release];

}


- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{

  if (buttonIndex == 0)

  {

    NSLog(@"exec");
    system("AlertScript");
    system("AlertScriptReset");

  }
  else
  {
    NSLog(@"cancel");
  }
}

- (void)activator:(LAActivator *)activator abortEvent:(LAEvent *)event
{
        [self dismiss];
}

+ (void)load
{
        
[[LAActivator sharedInstance] registerListener:[self new] forName:@"com.fhsjaagshs.alertscript"];
}
@end
2

2 Answers

0
votes

It is literally impossible to tell you what you are missing without the compiler output, which typically explains in full what is wrong with a given piece of code. Are you linking with libactivator, using "-lactivator" in your compiler commandline? How about UIKit and Foundation?

We aren't psychic. We can't tell you what is missing any more concisely than the compiler that actually gave you the error messages can.

0
votes

It turns out that I misnamed the - (void)activator Receive event thingy. Also the code is a very early version and it works quite well now.

http://www.github.com/fhsjaagshs/