iOS Question Problem GetField NativeObject

mayahandayani

Member
Licensed User
Hello...
I'm using NativeObject to CalendarEvent like this

B4X:
For Each e As CalendarEvent In Events
     Private no As NativeObject = e
Next

when I log the "no", the result like this :

B4X:
<B4INativeObject: EKEvent <0x28348d080>
[<EKEvent 0x280780160> valueForUndefinedKey:]: this class is not key value coding-compliant for the key recurrence.
{
     EKEvent <0x28348d080>
{     title =         test;
     location =     (null);
     calendar =     EKCalendar <0x2816d1580> {title = .....@gmail.com; type = CalDAV; allowsModify = YES; color = #CCA6ACFF;};
     alarms =         (
    "EKAlarm <0x2816d1300> {triggerInterval = -1800.000000}"
);
     URL =             (null);
     lastModified = 2024-05-28 7:19:11 AM +0000;
     startTimeZone =     Asia/Jakarta (GMT+7) offset 25200;
     endTimeZone =     Asia/Jakarta (GMT+7) offset 25200
};
     location =     (null);
     structuredLocation =     (null);
     startDate =     2024-06-05 5:00:00 AM +0000;
     endDate =         2024-06-05 6:00:00 AM +0000;
     allDay =         0;
     floating =     0;
     recurrence =     EKRecurrenceRule <0x2820ab0c0> RRULE FREQ=DAILY;INTERVAL=3;COUNT=5;
     travelTime =     (null);
     startLocation =     (null);
};>

Actually, I want to get all field like location, recurrence, etc
but when I try to GetField "recurrence" like this
B4X:
Private recurrence As NativeObject = no.GetField("recurrence")
I get error like this
B4X:
Error occurred on line: 322 (B4XMainPage)
[<EKEvent 0x282250a50> valueForUndefinedKey:]: this class is not key value coding-compliant for the key recurrence.
Stack Trace: (
  CoreFoundation       EEC1287D-059B-38C8-9BC1-58A0C8B1E6C2 + 601204
  libobjc.A.dylib      objc_exception_throw + 56
  CoreFoundation       EEC1287D-059B-38C8-9BC1-58A0C8B1E6C2 + 1430672
  Foundation           F9235FC7-EC4E-31C9-B56E-95CF10B07239 + 1339368
  Foundation           F9235FC7-EC4E-31C9-B56E-95CF10B07239 + 156824
  Business Calendar PRP V1            0x0000000104e006cc -[B4INativeObject GetField:] + 120
  CoreFoundation       EEC1287D-059B-38C8-9BC1-58A0C8B1E6C2 + 134384
  CoreFoundation       EEC1287D-059B-38C8-9BC1-58A0C8B1E6C2 + 249304
  Business Calendar PRP V1            0x0000000104deb768 +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1348
  Business Calendar PRP V1            0x0000000104e943e8 -[B4IShell runMethod:] + 320
 Business Calendar PRP V1            0x0000000104e9349c -[B4IShell raiseEventImpl:method:args::] + 928
 Business Calendar PRP V1            0x0000000104e95f1c -[B4IShellBI raiseEvent:event:params:] + 1008
 Business Calendar PRP V1            0x0000000104e9eb88 -[B4IDebugResumableSub resume::] + 292
 Business Calendar PRP V1            0x0000000104deb0f0 -[B4I checkAndRunWaitForEvent:event:params:] + 468
 Business Calendar PRP V1            0x0000000104e95eb4 -[B4IShellBI raiseEvent:event:params:] + 904
 Business Calendar PRP V1            0x0000000104df2c74 __37-[B4ICommon ReturnFromResumableSub::]_block_invoke + 256
 libdispatch.dylib    9CCDBDE3-15E1-3A45-B330-4A5E2C3F92BD + 405652
 libdispatch.dylib    9CCDBDE3-15E1-3A45-B330-4A5E2C3F92BD + 409748
 libdispatch.dylib    9CCDBDE3-15E1-3A45-B330-4A5E2C3F92BD + 68932
 libdispatch.dylib    9CCDBDE3-15E1-3A45-B330-4A5E2C3F92BD + 67988
 CoreFoundation       EEC1287D-059B-38C8-9BC1-58A0C8B1E6C2 + 319508
 CoreFoundation       EEC1287D-059B-38C8-9BC1-58A0C8B1E6C2 + 46328
 CoreFoundation       CFRunLoopRunSpecific + 572
 GraphicsServices     GSEventRunModal + 160
 UIKitCore            9D301877-2593-385C-8F72-F075AA0B48FA + 5134984
 UIKitCore            UIApplicationMain + 336
 Business Calendar PRP V1            0x0000000104a60064 main + 100
 dyld                 start + 444
)

Any idea?
Btw this is my first post so sorry if I make mistake

Thanks
 
Last edited:

mayahandayani

Member
Licensed User
Hi Erel! Thank you for your support..

Now I'm trying to add event with recurrencerule

B4X:
Dim ev As CalendarEvent = store.CreateEvent
Dim newEvent As NativeObject = ev

Dim recurrenceRule As NativeObject
recurrenceRule.Initialize("EKRecurrenceRule")
recurrenceRule.RunMethod("initRecurrenceWithFrequency:interval:end:", Array(1, 2, CreateRecurrenceEnd(5)))
Dim recurrenceRules As List
recurrenceRules.Initialize
recurrenceRules.Add(recurrenceRule)
newEvent.SetField("recurrenceRules", recurrenceRules)

B4X:
Sub CreateRecurrenceEnd(count As Int) As NativeObject
    Dim recurrenceEnd As NativeObject
    recurrenceEnd.Initialize("EKRecurrenceEnd")
    recurrenceEnd = recurrenceEnd.RunMethod("recurrenceEndWithOccurrenceCount:", Array(count))
    Return recurrenceEnd
End Sub

but I've got error like this
B4X:
Error occurred on line: 885
Method not found: initRecurrenceWithFrequency:interval:end:, target: EKRecurrenceRule
Stack Trace: (
  CoreFoundation       EEC1287D-059B-38C8-9BC1-58A0C8B1E6C2 + 601204
  libobjc.A.dylib      objc_exception_throw + 56
  CoreFoundation       EEC1287D-059B-38C8-9BC1-58A0C8B1E6C2 + 941668
  Business Calendar PRP V1            0x0000000100c66dfc +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 352
  Business Calendar PRP V1            0x0000000100c7bf8c -[B4INativeObject RunMethod::] + 176
  CoreFoundation       EEC1287D-059B-38C8-9BC1-58A0C8B1E6C2 + 134384
  CoreFoundation       EEC1287D-059B-38C8-9BC1-58A0C8B1E6C2 + 249304
  Business Calendar PRP V1            0x0000000100c671e0 +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1348
  Business Calendar PRP V1            0x0000000100d0fce4 -[B4IShell runVoidMethod] + 168
  Business Calendar PRP V1            0x0000000100d0f058 -[B4IShell raiseEventImpl:method:args::] + 1252
 Business Calendar PRP V1            0x0000000100d11994 -[B4IShellBI raiseEvent:event:params:] + 1008
 Business Calendar PRP V1            0x0000000100bf8970 -[b4i_pageinputjadwal _btnsimpan_click:] + 220
 Business Calendar PRP V1            0x0000000100bf8800 -[b4i_pageinputjadwal _b4xpage_menuclick::] + 468
 CoreFoundation       EEC1287D-059B-38C8-9BC1-58A0C8B1E6C2 + 134384
 CoreFoundation       EEC1287D-059B-38C8-9BC1-58A0C8B1E6C2 + 249304
 Business Calendar PRP V1            0x0000000100c671e0 +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1348
 Business Calendar PRP V1            0x0000000100d0fe60 -[B4IShell runMethod:] + 320
 Business Calendar PRP V1            0x0000000100d0ef14 -[B4IShell raiseEventImpl:method:args::] + 928
 Business Calendar PRP V1            0x0000000100d11994 -[B4IShellBI raiseEvent:event:params:] + 1008
 Business Calendar PRP V1            0x0000000100c66748 __33-[B4I raiseUIEvent:event:params:]_block_invoke + 52
 libdispatch.dylib    9CCDBDE3-15E1-3A45-B330-4A5E2C3F92BD + 405652
 libdispatch.dylib    9CCDBDE3-15E1-3A45-B330-4A5E2C3F92BD + 409748
 libdispatch.dylib    9CCDBDE3-15E1-3A45-B330-4A5E2C3F92BD + 68932
 libdispatch.dylib    9CCDBDE3-15E1-3A45-B330-4A5E2C3F92BD + 67988
 CoreFoundation       EEC1287D-059B-38C8-9BC1-58A0C8B1E6C2 + 319508
 CoreFoundation       EEC1287D-059B-38C8-9BC1-58A0C8B1E6C2 + 46328
 CoreFoundation       CFRunLoopRunSpecific + 572
 GraphicsServices     GSEventRunModal + 160
 UIKitCore            9D301877-2593-385C-8F72-F075AA0B48FA + 5134984
 UIKitCore            UIApplicationMain + 336
 Business Calendar PRP V1            0x00000001008d0064 main + 100
 dyld                 start + 444
)

Any solution?
Thanks
 
Last edited:
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
B4X:
Dim recurrenceRule As NativeObject
recurrenceRule = recurrenceRule.Initialize("EKRecurrenceRule").RunMethod("alloc", Null)
recurrenceRule.RunMethod("initRecurrenceWithFrequency:interval:end:", Array(1, 2, CreateRecurrenceEnd(5)))

The method signature starts with a minus sign: https://developer.apple.com/documen...273-initrecurrencewithfrequency?language=objc
This means that it is an instance method, not a class method.
To create an instance you need to call the "alloc" method.
 
Upvote 0

mayahandayani

Member
Licensed User
Hi Erel!
Thank you for your advice

I've tried it but the error is still same like on my previously reply, so I just add RunMethod("init",Null) and my code like this
B4X:
Dim recurrenceRule As NativeObject
recurrenceRule.Initialize("EKRecurrenceRule").RunMethod("alloc", Null).RunMethod("init",Null).RunMethod("initRecurrenceWithFrequency:interval:end:", Array(0, 2, CreateRecurrenceEnd(5)))
Dim recurrenceRules As List
recurrenceRules.Initialize
recurrenceRules.Add(recurrenceRule)
newEvent.SetField("recurrenceRules", recurrenceRules)

but I've got error on line
newEvent.SetField("recurrenceRules", recurrenceRules)

the error is
B4X:
Error occurred on line: 919 (pageInputJadwal)
+[EKRecurrenceRule frozenObject]: unrecognized selector sent to class 0x1f6aa8378
Stack Trace: (
  CoreFoundation       EEC1287D-059B-38C8-9BC1-58A0C8B1E6C2 + 601204
  libobjc.A.dylib      objc_exception_throw + 56
  CoreFoundation       EEC1287D-059B-38C8-9BC1-58A0C8B1E6C2 + 1455664
  CoreFoundation       EEC1287D-059B-38C8-9BC1-58A0C8B1E6C2 + 181580
  CoreFoundation       _CF_forwarding_prep_0 + 92
  EventKit             DACE06C2-9E39-368E-9829-288CA8D97AAE + 187680
  EventKit             DACE06C2-9E39-368E-9829-288CA8D97AAE + 398084
  Foundation           F9235FC7-EC4E-31C9-B56E-95CF10B07239 + 163704
  Business Calendar PRP V1            0x0000000105221d9c -[B4INativeObject SetField::] + 116
  CoreFoundation       EEC1287D-059B-38C8-9BC1-58A0C8B1E6C2 + 134384
 CoreFoundation       EEC1287D-059B-38C8-9BC1-58A0C8B1E6C2 + 249304
 Business Calendar PRP V1            0x000000010520cd60 +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1348
 Business Calendar PRP V1            0x00000001052b5864 -[B4IShell runVoidMethod] + 168
 Business Calendar PRP V1            0x00000001052b4bd8 -[B4IShell raiseEventImpl:method:args::] + 1252
 Business Calendar PRP V1            0x00000001052b7514 -[B4IShellBI raiseEvent:event:params:] + 1008
 Business Calendar PRP V1            0x0000000105198d74 -[b4i_pageinputjadwal _btnsimpan_click:] + 220
 Business Calendar PRP V1            0x0000000105198c04 -[b4i_pageinputjadwal _b4xpage_menuclick::] + 468
 CoreFoundation       EEC1287D-059B-38C8-9BC1-58A0C8B1E6C2 + 134384
 CoreFoundation       EEC1287D-059B-38C8-9BC1-58A0C8B1E6C2 + 249304
 Business Calendar PRP V1            0x000000010520cd60 +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1348
 Business Calendar PRP V1            0x00000001052b59e0 -[B4IShell runMethod:] + 320
 Business Calendar PRP V1            0x00000001052b4a94 -[B4IShell raiseEventImpl:method:args::] + 928
 Business Calendar PRP V1            0x00000001052b7514 -[B4IShellBI raiseEvent:event:params:] + 1008
 Business Calendar PRP V1            0x000000010520c2c8 __33-[B4I raiseUIEvent:event:params:]_block_invoke + 52
 libdispatch.dylib    9CCDBDE3-15E1-3A45-B330-4A5E2C3F92BD + 405652
 libdispatch.dylib    9CCDBDE3-15E1-3A45-B330-4A5E2C3F92BD + 409748
 libdispatch.dylib    9CCDBDE3-15E1-3A45-B330-4A5E2C3F92BD + 68932
 libdispatch.dylib    9CCDBDE3-15E1-3A45-B330-4A5E2C3F92BD + 67988
 CoreFoundation       EEC1287D-059B-38C8-9BC1-58A0C8B1E6C2 + 319508
 CoreFoundation       EEC1287D-059B-38C8-9BC1-58A0C8B1E6C2 + 46328
 CoreFoundation       CFRunLoopRunSpecific + 572
 GraphicsServices     GSEventRunModal + 160
 UIKitCore            9D301877-2593-385C-8F72-F075AA0B48FA + 5134984
 UIKitCore            UIApplicationMain + 336
 Business Calendar PRP V1            0x0000000104e70064 main + 100
 dyld                 start + 444
)

Note : log from recurrenceRules is
B4X:
recurrenceRules : <B4IList: (
    EKRecurrenceRule
)>

Any idea to fix that?
Thanks
 
Last edited:
Upvote 0

mayahandayani

Member
Licensed User
Hi Erel! Thank you so much, it works!

but I have one question about invitees
I want add some emails & my code like this
B4X:
Dim attendee As NativeObject
attendee.Initialize("EKParticipant")
Dim url As NativeObject
url.Initialize("NSURL")
url = url.RunMethod("URLWithString:", Array("mailto:" & "....@yahoo.com"))
Dim attend As List
attend.Initialize
attend.Add(url)
attendee.SetField("URL", attend)          
newEvent.SetField("attendees", Array(attendee))

and I've got error like this
B4X:
[<EKParticipant 0x1f64fca80> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key URL.

what's wrong?
thanks
 
Last edited:
Upvote 0