Skip to content

fix: convert URL string to NSURL before passing to setURL_#24

Open
XuanyouLiu wants to merge 1 commit intoOmar-V2:mainfrom
XuanyouLiu:fix/nsurl-type-conversion
Open

fix: convert URL string to NSURL before passing to setURL_#24
XuanyouLiu wants to merge 1 commit intoOmar-V2:mainfrom
XuanyouLiu:fix/nsurl-type-conversion

Conversation

@XuanyouLiu
Copy link
Copy Markdown

Summary

Fixes #23

  • EKEvent.setURL_() expects an NSURL object, but a plain Python string was being passed, causing NSInvalidArgumentException: [OC_BuiltinPythonUnicode absoluteString]: unrecognized selector
  • Import NSURL from Foundation and wrap URL strings with NSURL.URLWithString_() in both create_event and update_event code paths

Changes

  • src/mcp_ical/ical.py:
    • Added from Foundation import NSURL import
    • Changed ekevent.setURL_(new_event.url) to ekevent.setURL_(NSURL.URLWithString_(new_event.url)) (create path)
    • Changed existing_ek_event.setURL_(request.url) to existing_ek_event.setURL_(NSURL.URLWithString_(request.url)) (update path)

Test plan

  • Verified fix locally: created and updated calendar events with URL field successfully
  • Confirmed URL appears correctly in Apple Calendar after the fix

Made with Cursor

EKEvent.setURL_() expects an NSURL object, but a Python string was
being passed directly via PyObjC. This caused an NSInvalidArgumentException:

  [OC_BuiltinPythonUnicode absoluteString]: unrecognized selector

Fix by importing Foundation.NSURL and wrapping the URL string with
NSURL.URLWithString_() in both create_event and update_event paths.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: setURL_ crashes with NSInvalidArgumentException - expects NSURL, receives Python string

1 participant